6 print "Trying to connect to the example server -d..."
9 #wolfssl.wolfSSL_Debugging_ON()
10 ctx = wolfssl.wolfSSL_CTX_new(wolfssl.wolfTLSv1_2_client_method())
12 print "Couldn't get SSL CTX for TLSv1.2"
15 ret = wolfssl.wolfSSL_CTX_load_verify_locations(ctx, "../certs/ca-cert.pem", None)
16 if ret != wolfssl.SSL_SUCCESS:
17 print "Couldn't do SSL_CTX_load_verify_locations "
18 print "error string = ", ret
21 ssl = wolfssl.wolfSSL_new(ctx)
22 ret = wolfssl.wolfSSL_swig_connect(ssl, "localhost", 11111)
24 if ret != wolfssl.SSL_SUCCESS:
25 print "Couldn't do SSL connect"
26 err = wolfssl.wolfSSL_get_error(ssl, 0)
28 print "tcp error, is example server running?"
30 print "error string = ", wolfssl.wolfSSL_error_string(err)
34 written = wolfssl.wolfSSL_write(ssl, "hello from python\r\n", 19)
37 print "Wrote ", written, " bytes"
39 byteArray = wolfssl.byteArray(100)
40 readBytes = wolfssl.wolfSSL_read(ssl, byteArray, 100)
42 print "server reply: ", wolfssl.cdata(byteArray, readBytes)