From 1571ced095efdc13b0f23c050f1c28b83353e898 Mon Sep 17 00:00:00 2001 From: toddouska Date: Sun, 3 May 2015 10:19:02 -0700 Subject: [PATCH] update python example to TLSv1.2 against example server --- swig/README | 6 +++--- swig/runme.py | 11 +++++++---- swig/wolfssl.i | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/swig/README b/swig/README index bd4f7f7cf..d71cdb2b5 100644 --- a/swig/README +++ b/swig/README @@ -16,14 +16,14 @@ Please send questions to support@wolfssl.com sudo make install -2) start the example echoserver from the root directory - ./examples/echoserver/echoserver +2) start the example server from the root directory + ./examples/server/server -d 3) run ./PythonBuild.sh from this directory it will a) build the swig wrapper file b) compile the swig wrapper and wolfssl wrapper files c) place them into a wolfssl shared library for python - d) run runme.py which will connect to the wolfSSL echo server, write a + d) run runme.py which will connect to the wolfSSL server, write a string, then read the result and output it diff --git a/swig/runme.py b/swig/runme.py index cb2ddf11f..90fc43159 100644 --- a/swig/runme.py +++ b/swig/runme.py @@ -3,13 +3,13 @@ import wolfssl print "" -print "Trying to connect to the echo server..." +print "Trying to connect to the example server -d..." wolfssl.wolfSSL_Init() #wolfssl.wolfSSL_Debugging_ON() -ctx = wolfssl.wolfSSL_CTX_new(wolfssl.wolfTLSv1_client_method()) +ctx = wolfssl.wolfSSL_CTX_new(wolfssl.wolfTLSv1_2_client_method()) if ctx == None: - print "Couldn't get SSL CTX for TLSv1" + print "Couldn't get SSL CTX for TLSv1.2" exit(-1) ret = wolfssl.wolfSSL_CTX_load_verify_locations(ctx, "../certs/ca-cert.pem", None) @@ -24,7 +24,10 @@ ret = wolfssl.wolfSSL_swig_connect(ssl, "localhost", 11111) if ret != wolfssl.SSL_SUCCESS: print "Couldn't do SSL connect" err = wolfssl.wolfSSL_get_error(ssl, 0) - print "error string = ", wolfssl.wolfSSL_error_string(err) + if ret == -2: + print "tcp error, is example server running?" + else: + print "error string = ", wolfssl.wolfSSL_error_string(err) exit(-1) print "...Connected" diff --git a/swig/wolfssl.i b/swig/wolfssl.i index 45dc693d3..a03e79cbc 100644 --- a/swig/wolfssl.i +++ b/swig/wolfssl.i @@ -33,7 +33,7 @@ %} -WOLFSSL_METHOD* wolfTLSv1_client_method(void); +WOLFSSL_METHOD* wolfTLSv1_2_client_method(void); WOLFSSL_CTX* wolfSSL_CTX_new(WOLFSSL_METHOD*); int wolfSSL_CTX_load_verify_locations(WOLFSSL_CTX*, const char*, const char*); WOLFSSL* wolfSSL_new(WOLFSSL_CTX*);