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 :
@@ -480,13 +480,13 @@ def generate_config_section(
480
480
}
481
481
)
482
482
483
- def read_tls_certificate (self ):
483
+ def read_tls_certificate (self ) -> crypto . X509 :
484
484
"""Reads the TLS certificate from the configured file, and returns it
485
485
486
486
Also checks if it is self-signed, and warns if so
487
487
488
488
Returns:
489
- OpenSSL.crypto.X509: the certificate
489
+ The certificate
490
490
"""
491
491
cert_path = self .tls_certificate_file
492
492
logger .info ("Loading TLS certificate from %s" , cert_path )
@@ -505,11 +505,11 @@ def read_tls_certificate(self):
505
505
506
506
return cert
507
507
508
- def read_tls_private_key (self ):
508
+ def read_tls_private_key (self ) -> crypto . PKey :
509
509
"""Reads the TLS private key from the configured file, and returns it
510
510
511
511
Returns:
512
- OpenSSL.crypto.PKey: the private key
512
+ The private key
513
513
"""
514
514
private_key_path = self .tls_private_key_file
515
515
logger .info ("Loading TLS key from %s" , private_key_path )
0 commit comments