Commit fb6e6117 authored by Alexander Schrode's avatar Alexander Schrode Committed by oroulet

handle server certificate is none

parent caa898c4
......@@ -468,13 +468,15 @@ class Client:
data = self.security_policy.host_certificate + nonce
self.security_policy.asymmetric_cryptography.verify(data, response.ServerSignature.Signature)
self._server_nonce = response.ServerNonce
# If a server has certificate chain, the certificates are chained
# this generates a error in our crypto part, so we strip everything after
# the server cert. To do this we read byte 2:4 and get the length - 4
cert_len_idx = 2
len_bytestr = response.ServerCertificate[cert_len_idx:cert_len_idx + 2]
cert_len = int.from_bytes(len_bytestr, byteorder="big", signed=False) + 4
server_certificate = response.ServerCertificate[:cert_len]
server_certificate = None
if response.ServerCertificate is not None:
# If a server has certificate chain, the certificates are chained
# this generates a error in our crypto part, so we strip everything after
# the server cert. To do this we read byte 2:4 and get the length - 4
cert_len_idx = 2
len_bytestr = response.ServerCertificate[cert_len_idx:cert_len_idx + 2]
cert_len = int.from_bytes(len_bytestr, byteorder="big", signed=False) + 4
server_certificate = response.ServerCertificate[:cert_len]
if not self.security_policy.peer_certificate:
self.security_policy.peer_certificate = server_certificate
elif self.security_policy.peer_certificate != server_certificate:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment