get_certificate cleanup
This commit is contained in:
parent
ba7d28e931
commit
f21029e15b
2 changed files with 9 additions and 10 deletions
|
@ -237,9 +237,14 @@ class EasyRSA:
|
|||
|
||||
def get_certificate(
|
||||
self,
|
||||
cert_type: CertificateType | None,
|
||||
*,
|
||||
cert_type: CertificateType | None = None,
|
||||
dn: DistinguishedName | None = None,
|
||||
) -> x509.Certificate | None:
|
||||
"""
|
||||
Get a certificate from the PKI directory
|
||||
"""
|
||||
|
||||
if cert_type is CertificateType.ca:
|
||||
cert_filename = self.output_directory.joinpath("ca.crt")
|
||||
|
||||
|
@ -279,10 +284,7 @@ class EasyRSA:
|
|||
EASYRSA_REQ_CN="kiwi-vpn-ca",
|
||||
)
|
||||
|
||||
cert = self.get_certificate(
|
||||
cert_type=CertificateType.ca,
|
||||
dn=None,
|
||||
)
|
||||
cert = self.get_certificate(cert_type=CertificateType.ca)
|
||||
assert cert is not None
|
||||
|
||||
# # this takes long!
|
||||
|
@ -340,10 +342,7 @@ class EasyRSA:
|
|||
**dn.easyrsa_env,
|
||||
)
|
||||
|
||||
return self.get_certificate(
|
||||
cert_type=None,
|
||||
dn=dn,
|
||||
)
|
||||
return self.get_certificate(dn=dn)
|
||||
|
||||
def revoke(
|
||||
self,
|
||||
|
|
|
@ -145,7 +145,7 @@ async def get_pki() -> EasyRSA:
|
|||
- 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)
|
||||
|
||||
return EASYRSA
|
||||
|
|
Loading…
Reference in a new issue