Преглед изворни кода

update python example to TLSv1.2 against example server

toddouska пре 9 година
родитељ
комит
1571ced095
3 измењених фајлова са 11 додато и 8 уклоњено
  1. 3 3
      swig/README
  2. 7 4
      swig/runme.py
  3. 1 1
      swig/wolfssl.i

+ 3 - 3
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
 
 

+ 7 - 4
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"

+ 1 - 1
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*);