Module: check_mk
Branch: master
Commit: 07e51b49282786b81566cd9f7776a350632bca35
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=07e51b49282786…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Feb 5 17:41:42 2019 +0100
Fix type annotations
Change-Id: I6f8565259bee18662a1b4be7aa9fd74cb16d1342
---
omd/packages/omd/omdlib/certs.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/omd/packages/omd/omdlib/certs.py b/omd/packages/omd/omdlib/certs.py
index 5d7c2b1..7037786 100644
--- a/omd/packages/omd/omdlib/certs.py
+++ b/omd/packages/omd/omdlib/certs.py
@@ -65,7 +65,7 @@ class CertificateAuthority(object):
self._write_pem(self._root_cert_path, [root_cert], root_key)
def _create_root_certificate(self):
- # type: () -> Tuple[str, str]
+ # type: () -> Tuple[crypto.PKey, str]
key = self._make_private_key()
cert = self._make_cert(self._ca_name, CA_CERT_NOT_AFTER)
@@ -89,11 +89,11 @@ class CertificateAuthority(object):
return self.site_certificate_path(site_id).exists()
def read_site_certificate(self, site_id):
- # type: (str) -> str
+ # type: (str) -> Tuple[crypto.X509, crypto.PKey]
return self._read_pem(self.site_certificate_path(site_id))
def create_site_certificate(self, site_id):
- # type: (str) -> str
+ # type: (str) -> None
"""Creates the key / certificate for the given Check_MK
site"""
if not self.is_initialized:
raise Exception("Certificate authority is not initialized yet")
@@ -117,7 +117,7 @@ class CertificateAuthority(object):
self.write_site_certificate(site_id, cert, key)
def write_site_certificate(self, site_id, cert, key):
- # type: (str, str, str) -> None
+ # type: (str, crypto.X509, crypto.PKey) -> None
certificate_chain = [cert, self._get_root_certificate()[0]]
self._write_pem(self.site_certificate_path(site_id), certificate_chain, key)
@@ -126,7 +126,7 @@ class CertificateAuthority(object):
return (self.ca_path / "sites" /
site_id).with_suffix(".pem")
def _make_cert(self, cn, not_after):
- # type: (str, int) -> str
+ # type: (str, int) -> crypto.X509
cert = crypto.X509()
cert.set_serial_number(random.randint(0, sys.maxsize))
@@ -139,13 +139,13 @@ class CertificateAuthority(object):
return cert
def _make_private_key(self):
- # type: () -> str
+ # type: () -> crypto.PKey
key = crypto.PKey()
key.generate_key(crypto.TYPE_RSA, 2048)
return key
def _write_pem(self, path, certificate_chain, key):
- # type: (Path, List[str], str) -> None
+ # type: (Path, List[crypto.X509], crypto.PKey) -> None
path.parent.mkdir(mode=0o770, parents=True, exist_ok=True)
with path.open(mode="wb") as f:
f.write(crypto.dump_privatekey(FILETYPE_PEM, key))
@@ -154,7 +154,7 @@ class CertificateAuthority(object):
path.chmod(mode=0o660)
def _read_pem(self, path):
- # type: (Path) -> Tuple[str, str]
+ # type: (Path) -> Tuple[crypto.X509, crypto.PKey]
with path.open(mode="rb") as f:
file_contents = f.read()
cert = crypto.load_certificate(FILETYPE_PEM, file_contents)