get_certificate cleanup

This commit is contained in:
Jörn-Michael Miehe 2022-04-07 10:27:08 +00:00
parent ba7d28e931
commit f21029e15b
2 changed files with 9 additions and 10 deletions

View file

@ -237,9 +237,14 @@ class EasyRSA:
def get_certificate( def get_certificate(
self, self,
cert_type: CertificateType | None, *,
cert_type: CertificateType | None = None,
dn: DistinguishedName | None = None, dn: DistinguishedName | None = None,
) -> x509.Certificate | None: ) -> x509.Certificate | None:
"""
Get a certificate from the PKI directory
"""
if cert_type is CertificateType.ca: if cert_type is CertificateType.ca:
cert_filename = self.output_directory.joinpath("ca.crt") cert_filename = self.output_directory.joinpath("ca.crt")
@ -279,10 +284,7 @@ class EasyRSA:
EASYRSA_REQ_CN="kiwi-vpn-ca", EASYRSA_REQ_CN="kiwi-vpn-ca",
) )
cert = self.get_certificate( cert = self.get_certificate(cert_type=CertificateType.ca)
cert_type=CertificateType.ca,
dn=None,
)
assert cert is not None assert cert is not None
# # this takes long! # # this takes long!
@ -340,10 +342,7 @@ class EasyRSA:
**dn.easyrsa_env, **dn.easyrsa_env,
) )
return self.get_certificate( return self.get_certificate(dn=dn)
cert_type=None,
dn=dn,
)
def revoke( def revoke(
self, self,

View file

@ -145,7 +145,7 @@ async def get_pki() -> EasyRSA:
- 425: EasyRSA not initialized - 425: EasyRSA not initialized
""" """
if EASYRSA.get_certificate(CertificateType.ca) is None: if EASYRSA.get_certificate(cert_type=CertificateType.ca) is None:
raise HTTPException(status_code=status.HTTP_425_TOO_EARLY) raise HTTPException(status_code=status.HTTP_425_TOO_EARLY)
return EASYRSA return EASYRSA