18
18
import warnings
19
19
from datetime import datetime
20
20
from hashlib import sha256
21
- from typing import List
21
+ from typing import List , Optional
22
22
23
23
from unpaddedbase64 import encode_base64
24
24
@@ -177,8 +177,8 @@ def read_config(self, config: dict, config_dir_path: str, **kwargs):
177
177
"use_insecure_ssl_client_just_for_testing_do_not_use"
178
178
)
179
179
180
- self .tls_certificate = None
181
- self .tls_private_key = None
180
+ self .tls_certificate = None # type: Optional[crypto.X509]
181
+ self .tls_private_key = None # type: Optional[crypto.PKey]
182
182
183
183
def is_disk_cert_valid (self , allow_self_signed = True ):
184
184
"""
@@ -226,12 +226,12 @@ def is_disk_cert_valid(self, allow_self_signed=True):
226
226
days_remaining = (expires_on - now ).days
227
227
return days_remaining
228
228
229
- def read_certificate_from_disk (self , require_cert_and_key ):
229
+ def read_certificate_from_disk (self , require_cert_and_key : bool ):
230
230
"""
231
231
Read the certificates and private key from disk.
232
232
233
233
Args:
234
- require_cert_and_key (bool) : set to True to throw an error if the certificate
234
+ require_cert_and_key: set to True to throw an error if the certificate
235
235
and key file are not given
236
236
"""
237
237
if require_cert_and_key :
@@ -479,13 +479,13 @@ def generate_config_section(
479
479
}
480
480
)
481
481
482
- def read_tls_certificate (self ):
482
+ def read_tls_certificate (self ) -> crypto . X509 :
483
483
"""Reads the TLS certificate from the configured file, and returns it
484
484
485
485
Also checks if it is self-signed, and warns if so
486
486
487
487
Returns:
488
- OpenSSL.crypto.X509: the certificate
488
+ The certificate
489
489
"""
490
490
cert_path = self .tls_certificate_file
491
491
logger .info ("Loading TLS certificate from %s" , cert_path )
@@ -504,11 +504,11 @@ def read_tls_certificate(self):
504
504
505
505
return cert
506
506
507
- def read_tls_private_key (self ):
507
+ def read_tls_private_key (self ) -> crypto . PKey :
508
508
"""Reads the TLS private key from the configured file, and returns it
509
509
510
510
Returns:
511
- OpenSSL.crypto.PKey: the private key
511
+ The private key
512
512
"""
513
513
private_key_path = self .tls_private_key_file
514
514
logger .info ("Loading TLS key from %s" , private_key_path )
0 commit comments