how to create dtls server using pyopenssl

  Kiến thức lập trình

Im very new to this,
I need to do the following command as a python code using the library pyopenssl.

openssl s_server -dtls -cert certfile -key keyfile -cert_chain chainfile -accept ipaddress:port

Ive managed to do client using pyopenssl that works with that command in cmd – successfull handshake and i can write messages from 1 to another.

but I cant do the server properly I always get errors – ‘no shared cipher’, even there is shared ciphers. (i checked the ciphers sent in wireshark and printed all the cipher in the library)

this is my client code that works perfectly:

import socket
from OpenSSL import SSL

# Initialize the OpenSSL context

# Create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# Set up the client-side SSL socket
ssl_sock = SSL.Connection(context, sock)
# Perform the handshake
ssl_sock.connect((SERVER_ADDR, SERVER_PORT))

# Send data to the server
message = "Hello, DTLS server!"

# Receive data from the server
data = ssl_sock.recv(1024)
print(f"Received from server: {data.decode()}")

I tried different cipher suites and checked every time but it fails,
I just need help with creating the DTLS server.
I understand that server suppose the have a lot sort of data and options but I don’t know how to configured it correctly

New contributor

some random dude is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website