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: ...@@ -468,13 +468,15 @@ class Client:
data = self.security_policy.host_certificate + nonce data = self.security_policy.host_certificate + nonce
self.security_policy.asymmetric_cryptography.verify(data, response.ServerSignature.Signature) self.security_policy.asymmetric_cryptography.verify(data, response.ServerSignature.Signature)
self._server_nonce = response.ServerNonce self._server_nonce = response.ServerNonce
# If a server has certificate chain, the certificates are chained server_certificate = None
# this generates a error in our crypto part, so we strip everything after if response.ServerCertificate is not None:
# the server cert. To do this we read byte 2:4 and get the length - 4 # If a server has certificate chain, the certificates are chained
cert_len_idx = 2 # this generates a error in our crypto part, so we strip everything after
len_bytestr = response.ServerCertificate[cert_len_idx:cert_len_idx + 2] # the server cert. To do this we read byte 2:4 and get the length - 4
cert_len = int.from_bytes(len_bytestr, byteorder="big", signed=False) + 4 cert_len_idx = 2
server_certificate = response.ServerCertificate[:cert_len] 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: if not self.security_policy.peer_certificate:
self.security_policy.peer_certificate = server_certificate self.security_policy.peer_certificate = server_certificate
elif 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