porting socket ssl python to c++

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

porting socket ssl python to c++

Roberto Spadim
hi guys, i'm with a newbie question


i have this piece of code, but i'm not finding something similar with c++, could anyone help? thanks:


import socket
import ssl
import sys
if len(sys.argv) == 3:
HOST = sys.argv[1] # IP
PORT = int(sys.argv[2]) # Port
else:
print "USAGE: $python client_ssl.py <server_ip> <port>"
exit(1)
print 'Connecting...'
s = socket.create_connection((HOST, PORT))
s = ssl.wrap_socket(s)
print "Connected!\n"
while True:
query = raw_input("Query: ")
if ( query == "quit" ):
break
s.send(query)
data = s.recv(16384)
print 'Reply:', data
s.close()



--
Roberto Spadim

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: porting socket ssl python to c++

Wim Lewis-3
This pair of articles is quite old, so some of the API details have changed, but it has an overall description of how to use OpenSSL:
   https://www.linuxjournal.com/article/4822
   https://www.linuxjournal.com/article/5487

The link to the example code is broken, but you can find it here:
   https://github.com/Andersbakken/openssl-examples/

One thing to be aware of is that the check_cert() function is just a sketch of what a real check_cert() function would need to do (which depends on your application, to some extent). There are some functions that have been added to OpenSSL since then that, AIUI, can replace having to do those checks in your own check_cert():
    https://www.openssl.org/docs/man1.1.0/crypto/X509_check_host.html


--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users