fix: enable DTLS peer verification against Samsung OCF Root CA
Bundle certs/ocf_root_ca.pem as samsung_appliance/ocf_root_ca.pem and switch from SSL.VERIFY_NONE to SSL.VERIFY_PEER. The appliance's server certificate must now chain to the Samsung Electronics OCF Root CA, closing the ARP-spoof / MITM attack surface on the local network. .gitignore: carve out explicit exception for the bundled public CA cert.
This commit is contained in:
1 parent
ceab7585d9
commit
d5dc92e673
4 files changed
+28
-14
No files matched your search
@@ -23,9 +23,12 @@ import socket
|
||||
import struct
|
||||
import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from OpenSSL import SSL
|
||||
|
||||
_OCF_ROOT_CA = str(Path(__file__).parent / 'ocf_root_ca.pem')
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -226,7 +229,8 @@ class DtlsCoapSession:
|
||||
"""DTLS handshake. Blocks up to HANDSHAKE_TIMEOUT_S. Raises
|
||||
ConnectionError / TimeoutError on failure."""
|
||||
ctx = SSL.Context(SSL.DTLS_METHOD)
|
||||
ctx.set_verify(SSL.VERIFY_NONE, lambda *_: True)
|
||||
ctx.load_verify_locations(_OCF_ROOT_CA)
|
||||
ctx.set_verify(SSL.VERIFY_PEER, lambda conn, cert, err, depth, ok: ok)
|
||||
ctx.set_cipher_list(b'ECDHE-ECDSA-AES128-GCM-SHA256')
|
||||
ctx.use_certificate_chain_file(self.cert_path)
|
||||
ctx.use_privatekey_file(self.key_path)
|
||||
|
||||
Reference in new issue
Block a user