diff --git a/.gitignore b/.gitignore index b25accc55..bb8457b80 100644 --- a/.gitignore +++ b/.gitignore @@ -61,4 +61,8 @@ TAGS support/libcyassl.pc cyassl/version.h cyassl/ctaocrypt/stamp-h1 +swig/_cyassl.so +swig/cyassl.py +swig/cyassl.pyc +swig/cyassl_wrap.c stamp-h1 diff --git a/swig/PythonBuild.sh b/swig/PythonBuild.sh index 0fc2a880a..7f0939c42 100755 --- a/swig/PythonBuild.sh +++ b/swig/PythonBuild.sh @@ -3,7 +3,7 @@ echo swig -python cyassl.i pythonIncludes=`python-config --includes` pythonLibs=`python-config --libs` -gcc -c -fpic cyassl_wrap.c -I$pythonIncludes -I/usr/local/cyassl/include -DHAVE_CONFIG_H -gcc -c -fpic cyassl_adds.c -I/usr/local/cyassl/include -gcc -shared -flat_namespace cyassl_adds.o cyassl_wrap.o -lcyassl -L/usr/local/cyassl/lib $pythonLibs -o _cyassl.so +gcc -c -fpic cyassl_wrap.c -I$pythonIncludes +gcc -c -fpic cyassl_adds.c +gcc -shared -flat_namespace cyassl_adds.o cyassl_wrap.o -lcyassl $pythonLibs -o _cyassl.so python runme.py diff --git a/swig/cyassl.i b/swig/cyassl.i index d37ba3581..46253dc1a 100644 --- a/swig/cyassl.i +++ b/swig/cyassl.i @@ -21,12 +21,12 @@ %module cyassl %{ - #include "openssl/ssl.h" - #include "rsa.h" + #include + #include /* defn adds */ char* CyaSSL_error_string(int err); - int CyaSSL_connect(SSL*, const char* server, int port); + int CyaSSL_swig_connect(SSL*, const char* server, int port); RNG* GetRng(void); RsaKey* GetRsaPrivateKey(const char* file); void FillSignStr(unsigned char*, const char*, int); @@ -39,8 +39,10 @@ int SSL_CTX_load_verify_locations(SSL_CTX*, const char*, const char*); SSL* SSL_new(SSL_CTX*); int SSL_get_error(SSL*, int); int SSL_write(SSL*, const char*, int); +int CyaSSL_Debugging_ON(void); +int CyaSSL_Init(void); char* CyaSSL_error_string(int); -int CyaSSL_connect(SSL*, const char* server, int port); +int CyaSSL_swig_connect(SSL*, const char* server, int port); int RsaSSL_Sign(const unsigned char* in, int inLen, unsigned char* out, int outLen, RsaKey* key, RNG* rng); diff --git a/swig/cyassl_adds.c b/swig/cyassl_adds.c index 49a9303f1..a34c7a54f 100644 --- a/swig/cyassl_adds.c +++ b/swig/cyassl_adds.c @@ -160,7 +160,7 @@ static int tcp_connect(SOCKET_T* sockfd, const char* ip, short port) } -int CyaSSL_connect(SSL* ssl, const char* server, int port) +int CyaSSL_swig_connect(SSL* ssl, const char* server, int port) { SOCKET_T sockfd; int ret = tcp_connect(&sockfd, server, port); diff --git a/swig/runme.py b/swig/runme.py index 1734a0196..a3c81ae2b 100644 --- a/swig/runme.py +++ b/swig/runme.py @@ -5,11 +5,21 @@ import cyassl print "" print "Trying to connect to the echo server..." +cyassl.CyaSSL_Init() +#cyassl.CyaSSL_Debugging_ON() ctx = cyassl.SSL_CTX_new(cyassl.TLSv1_client_method()) -ret = cyassl.SSL_CTX_load_verify_locations(ctx, "../certs/ca-cert.pem", None) -ssl = cyassl.SSL_new(ctx) +if ctx == None: + print "Couldn't get SSL CTX for TLSv1" + exit(-1) -ret = cyassl.CyaSSL_connect(ssl, "localhost", 11111) +ret = cyassl.SSL_CTX_load_verify_locations(ctx, "../certs/ca-cert.pem", None) +if ret != cyassl.SSL_SUCCESS: + print "Couldn't do SSL_CTX_load_verify_locations " + print "error string = ", ret + exit(-1) + +ssl = cyassl.SSL_new(ctx) +ret = cyassl.CyaSSL_swig_connect(ssl, "localhost", 11111) if ret != cyassl.SSL_SUCCESS: print "Couldn't do SSL connect"