MCPcopy Create free account
hub / github.com/Syncplay/syncplay / handshakeCompleted

Method handshakeCompleted

syncplay/protocols.py:397–431  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

395 self.handshakeCompleted()
396
397 def handshakeCompleted(self):
398 self._serverCertificateTLS = self.transport.getPeerCertificate()
399 if not self._serverCertificateTLS:
400 self._client.ui.showErrorMessage(getMessage("startTLS-server-certificate-invalid"))
401 self.sendHello()
402 return
403
404 for x in range(0,self._serverCertificateTLS.get_extension_count()):
405 if (self._serverCertificateTLS.get_extension(x).get_short_name() == b'subjectAltName'):
406 self._subjectTLS = self._serverCertificateTLS.get_extension(x).__str__().replace("DNS:", "")
407
408 if not self._subjectTLS:
409 self._subjectTLS = self._client._config.get("host", "") or ""
410
411 self._issuerTLS = self._serverCertificateTLS.get_issuer().CN
412 self._expiredTLS =self._serverCertificateTLS.has_expired()
413 self._expireDateTLS = datetime.strptime(self._serverCertificateTLS.get_notAfter().decode('ascii'), '%Y%m%d%H%M%SZ')
414
415 self._encryptedConnectionTLS = self.transport.protocol._tlsConnection
416 self._connVersionNumberTLS = self._encryptedConnectionTLS.get_protocol_version()
417 self._connVersionStringTLS = self._encryptedConnectionTLS.get_protocol_version_name()
418 self._cipherNameTLS = self._encryptedConnectionTLS.get_cipher_name()
419
420 if self._connVersionNumberTLS == 771:
421 self._connVersionNumberTLS = '1.2'
422 elif self._connVersionNumberTLS == 772:
423 self._connVersionNumberTLS = '1.3'
424
425 self._client.ui.showMessage(getMessage("startTLS-secure-connection-ok").format(self._connVersionStringTLS))
426 self._client.ui.setSSLMode( True,
427 {'subject': self._subjectTLS, 'issuer': self._issuerTLS, 'expires': self._expireDateTLS,
428 'protocolString': self._connVersionStringTLS, 'protocolVersion': self._connVersionNumberTLS,
429 'cipher': self._cipherNameTLS})
430
431 self.sendHello()
432
433
434class SyncServerProtocol(JSONCommandProtocol):

Callers 1

Calls 6

sendHelloMethod · 0.95
getMessageFunction · 0.90
__str__Method · 0.80
showErrorMessageMethod · 0.45
showMessageMethod · 0.45
setSSLModeMethod · 0.45

Tested by

no test coverage detected