Skip to content
Open
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
72ba0b6
make runnable with OpenSSL 3 in addition to other versions
kashikoibumi May 20, 2024
f181b85
replace all of arg() occurrences to format()
kashikoibumi May 22, 2024
046a29e
stop using QString
kashikoibumi May 23, 2024
f70aff6
use import paths compatible with both Python2 and Python3
kashikoibumi May 24, 2024
f37a973
use six.PY2 and six.PY3
kashikoibumi May 25, 2024
46d56c7
use six.itervalues(), six.iteritems()
kashikoibumi May 25, 2024
21a7bdb
use six.int2byte(), six.byte2int, six.BytesIO
kashikoibumi May 25, 2024
81a6bdb
use six.assertRaisesRegex, six.assertRegex, six.assertNotRegex
kashikoibumi May 25, 2024
a11df0c
use six.moves
kashikoibumi May 26, 2024
4ee9986
Merge branch 'six' into py3
kashikoibumi May 26, 2024
d4bb580
fix importing collections for Python3
kashikoibumi May 26, 2024
e0c2976
Merge branch 'six' into py3
kashikoibumi May 26, 2024
ba49d32
use binary literals for compatibility to Python3
kashikoibumi May 26, 2024
4309cb3
use buffer() in Python2 and use memoryview in Python3
kashikoibumi May 26, 2024
a4c4338
use bytes() on keys to be hashable in Python3
kashikoibumi May 26, 2024
5ccfd52
Merge branch 'bytes-key' into py3
kashikoibumi May 26, 2024
0f858bc
read from and write to SQLite database in binary mode
kashikoibumi May 26, 2024
d38f425
fix address validator to work
kashikoibumi May 26, 2024
96c764b
refined: read from and write to SQLite database in binary mode
kashikoibumi May 27, 2024
2a0d2d3
update translation files for using format() instead of arg()
kashikoibumi May 26, 2024
9c64db0
remove restriction for Python3 and add startup script for Python3
kashikoibumi May 27, 2024
b9bfa51
fix import path compatible with both Python2 and Python3
kashikoibumi May 27, 2024
5fa08f4
misc fixes to run with Python3
kashikoibumi May 27, 2024
6ec9fb1
Merge branch 'binary' into py3
kashikoibumi May 27, 2024
df2631c
misc fixes to run with Python3; part 2
kashikoibumi May 28, 2024
0fa71f2
Merge branch 'openssl3' into py3
kashikoibumi May 28, 2024
10e5563
misc fixes to run with Python3; part 3
kashikoibumi May 28, 2024
c3d083d
Merge branch 'memoryview' into py3
kashikoibumi May 28, 2024
822b90e
fix to connect with TLS in Python3
kashikoibumi May 28, 2024
e5c0654
fix types
kashikoibumi May 29, 2024
c39dd18
fix one of database compatibility problems; others remained
kashikoibumi May 29, 2024
d9efe1c
fix for newer versions of Python3
kashikoibumi May 30, 2024
d676ea3
quick workaround for BLOB as TEXT problem (#2247)
kashikoibumi May 30, 2024
35abdf2
Merge branch 'v0.6' into py3
kashikoibumi May 30, 2024
01296a8
Merge branch 'strict-blob' into py3
kashikoibumi May 30, 2024
0795359
fix careless mistakes
kashikoibumi May 30, 2024
31dcbd6
add script to revert BLOB-keys into TEXT-keys
kashikoibumi May 30, 2024
0ff6b43
fix imports
kashikoibumi May 30, 2024
0739f53
Merge branch 'strict-blob' into py3
kashikoibumi May 30, 2024
f07af4e
fix TLS configuration bug
kashikoibumi May 30, 2024
e166116
disable UPnP in Python3 temporally
kashikoibumi May 30, 2024
a6e980d
use hexlify() to display hash ID
kashikoibumi May 30, 2024
a1d633d
workaround to invalid tag type
kashikoibumi May 30, 2024
08650d5
fix unexpected label string
kashikoibumi May 30, 2024
5af72b0
fix user agent format on debug log
kashikoibumi May 30, 2024
5973725
fix to pass tests
kashikoibumi May 31, 2024
ba8ccfc
fix bug on dandelion specific with Python3
kashikoibumi May 31, 2024
f9d2364
fix bug in chunked database access
kashikoibumi May 31, 2024
f8919a8
fix bug in responsibility of message list on Qt GUI
kashikoibumi May 31, 2024
9adcd1b
fix SOCKS
kashikoibumi May 31, 2024
d103297
fix UPnP to work with Python3
kashikoibumi Jun 1, 2024
0c110b9
fix to be runnable with prctl module in Python3
kashikoibumi Jun 3, 2024
11ba022
fix bug in detecting file system type
kashikoibumi Jun 22, 2024
cdcffa4
fix timestamp type mismatch bug
kashikoibumi Jun 24, 2024
e7b5f29
use SafeConfigParser or ConfigParser, which is available
kashikoibumi Jun 24, 2024
8bfcc4c
add comments
kashikoibumi Jun 25, 2024
da58e00
Merge branch 'v0.6' into py3
kashikoibumi Jun 30, 2024
c194943
Merge branch 'v0.6' into py3
kashikoibumi Aug 2, 2024
37bbe44
fix bug in generating deterministic address
kashikoibumi Aug 2, 2024
54cf229
Merge branch 'v0.6' into py3
kashikoibumi Sep 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
make runnable with OpenSSL 3 in addition to other versions
  • Loading branch information
kashikoibumi committed May 20, 2024
commit 72ba0b6bc17eecbfce3f50adbbbd828ed893a865
48 changes: 40 additions & 8 deletions src/network/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,44 @@ def __init__(self, _=None, sock=None, certfile=None, keyfile=None,
self.tlsDone = False
self.tlsVersion = "N/A"
self.isSSL = False
if ssl.OPENSSL_VERSION_NUMBER >= 0x30000000:
self.tlsPrepared = False

def state_tls_init(self):
"""Prepare sockets for TLS handshake"""
self.isSSL = True
self.tlsStarted = True

if ssl.OPENSSL_VERSION_NUMBER >= 0x30000000:
self.want_read = self.want_write = True
self.set_state("tls_handshake")
return False

do_tls_init(self)

def do_tls_init(self):
# Once the connection has been established,
# it's safe to wrap the socket.
if sys.version_info >= (2, 7, 9):
context = ssl.create_default_context(
purpose=ssl.Purpose.SERVER_AUTH
if self.server_side else ssl.Purpose.CLIENT_AUTH)
if ssl.OPENSSL_VERSION_NUMBER >= 0x30000000:
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
else:
context = ssl.create_default_context(
purpose=ssl.Purpose.SERVER_AUTH
if self.server_side else ssl.Purpose.CLIENT_AUTH)
context.set_ciphers(self.ciphers)
context.set_ecdh_curve("secp256k1")
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
# also exclude TLSv1 and TLSv1.1 in the future
context.options = ssl.OP_ALL | ssl.OP_NO_SSLv2 |\
ssl.OP_NO_SSLv3 | ssl.OP_SINGLE_ECDH_USE |\
ssl.OP_CIPHER_SERVER_PREFERENCE
if ssl.OPENSSL_VERSION_NUMBER >= 0x30000000:
context.options = ssl.OP_ALL | ssl.OP_NO_SSLv2 |\
ssl.OP_NO_SSLv3 | ssl.OP_SINGLE_ECDH_USE |\
ssl.OP_CIPHER_SERVER_PREFERENCE | ssl.OP_NO_TLS1_3
else:
context.options = ssl.OP_ALL | ssl.OP_NO_SSLv2 |\
ssl.OP_NO_SSLv3 | ssl.OP_SINGLE_ECDH_USE |\
ssl.OP_CIPHER_SERVER_PREFERENCE
self.sslSocket = context.wrap_socket(
self.socket, server_side=self.server_side,
do_handshake_on_connect=False)
Expand All @@ -88,7 +107,10 @@ def state_tls_init(self):
ciphers=self.ciphers, do_handshake_on_connect=False)
self.sslSocket.setblocking(0)
self.want_read = self.want_write = True
self.set_state("tls_handshake")
if ssl.OPENSSL_VERSION_NUMBER >= 0x30000000:
self.tlsPrepared = True
else:
self.set_state("tls_handshake")
return False

@staticmethod
Expand All @@ -114,7 +136,9 @@ def readable(self):
# during TLS handshake, and after flushing write buffer,
# return status of last handshake attempt
if self.tlsStarted and not self.tlsDone and not self.write_buf:
logger.debug('tls readable, %r', self.want_read)
# with OpenSSL 3, excessive logs are spitted
if ssl.OPENSSL_VERSION_NUMBER < 0x30000000:
logger.debug('tls readable, %r', self.want_read)
return self.want_read
# prior to TLS handshake,
# receiveDataThread should emulate synchronous behaviour
Expand All @@ -134,6 +158,10 @@ def handle_read(self):
try:
# wait for write buffer flush
if self.tlsStarted and not self.tlsDone and not self.write_buf:
if ssl.OPENSSL_VERSION_NUMBER >= 0x30000000:
if not self.tlsPrepared:
self.do_tls_init()
return
self.tls_handshake()
else:
AdvancedDispatcher.handle_read(self)
Expand All @@ -156,6 +184,10 @@ def handle_write(self):
try:
# wait for write buffer flush
if self.tlsStarted and not self.tlsDone and not self.write_buf:
if ssl.OPENSSL_VERSION_NUMBER >= 0x30000000:
if not self.tlsPrepared:
self.do_tls_init()
return
self.tls_handshake()
else:
AdvancedDispatcher.handle_write(self)
Expand Down