Lines Matching refs:self

75     def __init__(self, name: Optional[str] = None,  argument
85 self._name = name
86 self.domains = domains
87 self.client = client
88 self.email = email
89 self.key_type = key_type
90 self.single_file = single_file
91 self.valid_from = valid_from
92 self.valid_to = valid_to
93 self.sub_specs = sub_specs
94 self.check_valid = check_valid
97 def name(self) -> Optional[str]: argument
98 if self._name:
99 return self._name
100 elif self.domains:
101 return self.domains[0]
105 def type(self) -> Optional[str]: argument
106 if self.domains and len(self.domains):
108 elif self.client:
110 elif self.name:
117 def __init__(self, argument
122 self._name = name
123 self._cert = cert
124 self._pkey = pkey
125 self._issuer = issuer
126 self._cert_file = None
127 self._pkey_file = None
128 self._store = None
129 self._combined_file = None
132 def name(self) -> str: argument
133 return self._name
136 def subject(self) -> x509.Name: argument
137 return self._cert.subject
140 def key_type(self): argument
141 if isinstance(self._pkey, RSAPrivateKey):
143 elif isinstance(self._pkey, EllipticCurvePrivateKey):
149 def private_key(self) -> Any: argument
150 return self._pkey
153 def certificate(self) -> Any: argument
154 return self._cert
157 def cert_pem(self) -> bytes: argument
158 return self._cert.public_bytes(Encoding.PEM)
161 def pkey_pem(self) -> bytes: argument
162 return self._pkey.private_bytes(
164 … PrivateFormat.TraditionalOpenSSL if self.key_type.startswith('rsa') else PrivateFormat.PKCS8,
168 def issuer(self) -> Optional['Credentials']: argument
169 return self._issuer
171 def set_store(self, store: 'CertStore'): argument
172 self._store = store
174 def set_files(self, cert_file: str, pkey_file: Optional[str] = None, argument
176 self._cert_file = cert_file
177 self._pkey_file = pkey_file
178 self._combined_file = combined_file
181 def cert_file(self) -> str: argument
182 return self._cert_file
185 def pkey_file(self) -> Optional[str]: argument
186 return self._pkey_file
189 def combined_file(self) -> Optional[str]: argument
190 return self._combined_file
192 def get_first(self, name) -> Optional['Credentials']: argument
193 creds = self._store.get_credentials_for_name(name) if self._store else []
196 def get_credentials_for_name(self, name) -> List['Credentials']: argument
197 return self._store.get_credentials_for_name(name) if self._store else []
199 def issue_certs(self, specs: List[CertificateSpec], argument
201 return [self.issue_cert(spec=spec, chain=chain) for spec in specs]
203 def issue_cert(self, spec: CertificateSpec, argument
205 key_type = spec.key_type if spec.key_type else self.key_type
207 if self._store:
208 creds = self._store.load_credentials(
210 issuer=self, check_valid=spec.check_valid)
212 creds = TestCA.create_credentials(spec=spec, issuer=self, key_type=key_type,
214 if self._store:
215 self._store.save(creds, single_file=spec.single_file)
217 self._store.save_chain(creds, "ca", with_root=True)
220 if self._store:
221 sub_store = CertStore(fpath=os.path.join(self._store.path, creds.name))
224 subchain.append(self)
231 def __init__(self, fpath: str): argument
232 self._store_dir = fpath
233 if not os.path.exists(self._store_dir):
234 os.makedirs(self._store_dir)
235 self._creds_by_name = {}
238 def path(self) -> str: argument
239 return self._store_dir
241 def save(self, creds: Credentials, name: Optional[str] = None, argument
245 cert_file = self.get_cert_file(name=name, key_type=creds.key_type)
246 pkey_file = self.get_pkey_file(name=name, key_type=creds.key_type)
247 comb_file = self.get_combined_file(name=name, key_type=creds.key_type)
267 self._add_credentials(name, creds)
269 def save_chain(self, creds: Credentials, infix: str, with_root=False): argument
277 chain_file = os.path.join(self._store_dir, f'{name}-{infix}.pem')
282 def _add_credentials(self, name: str, creds: Credentials): argument
283 if name not in self._creds_by_name:
284 self._creds_by_name[name] = []
285 self._creds_by_name[name].append(creds)
287 def get_credentials_for_name(self, name) -> List[Credentials]: argument
288 return self._creds_by_name[name] if name in self._creds_by_name else []
290 def get_cert_file(self, name: str, key_type=None) -> str: argument
292 return os.path.join(self._store_dir, f'{name}{key_infix}.cert.pem')
294 def get_pkey_file(self, name: str, key_type=None) -> str: argument
296 return os.path.join(self._store_dir, f'{name}{key_infix}.pkey.pem')
298 def get_combined_file(self, name: str, key_type=None) -> str: argument
299 return os.path.join(self._store_dir, f'{name}.pem')
301 def load_pem_cert(self, fpath: str) -> x509.Certificate: argument
305 def load_pem_pkey(self, fpath: str): argument
309 def load_credentials(self, name: str, key_type=None, argument
313 cert_file = self.get_cert_file(name=name, key_type=key_type)
314 pkey_file = cert_file if single_file else self.get_pkey_file(name=name, key_type=key_type)
315 comb_file = self.get_combined_file(name=name, key_type=key_type)
317 cert = self.load_pem_cert(cert_file)
318 pkey = self.load_pem_pkey(pkey_file)
332 creds.set_store(self)
334 self._add_credentials(name, creds)