| 224 | self._add_credentials(name, creds) |
| 225 | |
| 226 | def save_chain(self, creds: Credentials, infix: str, with_root=False): |
| 227 | name = creds.name |
| 228 | chain = [creds] |
| 229 | while creds.issuer is not None: |
| 230 | creds = creds.issuer |
| 231 | chain.append(creds) |
| 232 | if not with_root and len(chain) > 1: |
| 233 | chain = chain[:-1] |
| 234 | chain_file = os.path.join(self._store_dir, f'{name}-{infix}.pem') |
| 235 | with open(chain_file, "wb") as fd: |
| 236 | for c in chain: |
| 237 | fd.write(c.cert_pem) |
| 238 | |
| 239 | def _add_credentials(self, name: str, creds: Credentials): |
| 240 | if name not in self._creds_by_name: |