1

I am working on implementation of a secure communication protocol between a client C and a server S using Python. For the purpose of making the communication secure (i.e. the messages transferred between C and S are confidential, authenticated and integrity is maintained), I need IDs of both C and S for making it possible.

I tried the following:

import socket
import sys
import hashlib
def server_register():
    name = gethostname()
    hostid = socket.gethostbyaddr(name)

However, this gives me the hostid = 127.0.1.1 which is the IP address of the local host. Also, as the IP addresses are dynamic in nature, I think it is not appropriate to use them as the ID for either of the devices.

How can I get the IDs of the client and the server in Python (considering that the IDs will remain constant/fixed throughout the communication?

Ankush Soni
  • 145
  • 10
  • 2
    What makes you think there are any unique **IDs** to retrieve? That is not how sockets represent parties. In any case, to secure a connection, all you really need is SSL/TLS and certificates. Don't try to implement your own system for this. – Remy Lebeau Jul 07 '22 at 19:34

0 Answers0