Repository: qpid-proton
Updated Branches:
  refs/heads/master 7b91e1ffe -> b4e06d34a


PROTON-750: Have explicit API to detect ssl if present
- avoids overloading other functionality for this purpose.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/2794da59
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/2794da59
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/2794da59

Branch: refs/heads/master
Commit: 2794da59b7ee8810a88b4393dacd87a947c10fe7
Parents: b57f45d
Author: Andrew Stitcher <astitc...@apache.org>
Authored: Thu Oct 30 15:03:32 2014 -0400
Committer: Andrew Stitcher <astitc...@apache.org>
Committed: Mon Nov 17 14:50:29 2014 -0500

----------------------------------------------------------------------
 proton-c/bindings/python/proton.py  |  4 ++++
 proton-c/include/proton/ssl.h       |  6 ++++++
 proton-c/src/ssl/openssl.c          |  5 +++++
 proton-c/src/ssl/ssl_stub.c         |  5 +++++
 proton-c/src/windows/schannel.c     |  7 +++++--
 proton-j/src/main/resources/cssl.py |  3 +++
 tests/python/proton_tests/common.py | 12 ++----------
 7 files changed, 30 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2794da59/proton-c/bindings/python/proton.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton.py 
b/proton-c/bindings/python/proton.py
index 00c36c0..81104f0 100644
--- a/proton-c/bindings/python/proton.py
+++ b/proton-c/bindings/python/proton.py
@@ -3270,6 +3270,10 @@ class SSLDomain(object):
 
 class SSL(object):
 
+  @staticmethod
+  def present():
+    return pn_ssl_present()
+
   def _check(self, err):
     if err < 0:
       exc = EXCEPTIONS.get(err, SSLException)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2794da59/proton-c/include/proton/ssl.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/ssl.h b/proton-c/include/proton/ssl.h
index 013478e..09d386b 100644
--- a/proton-c/include/proton/ssl.h
+++ b/proton-c/include/proton/ssl.h
@@ -90,6 +90,12 @@ typedef enum {
   PN_SSL_RESUME_REUSED          /**< Session resumed from previous session. */
 } pn_ssl_resume_status_t;
 
+/** Tests for SSL implementation present
+ *
+ *  @return true if we support SSL, false if not
+ */
+PN_EXTERN bool pn_ssl_present( void );
+
 /** Create an SSL configuration domain
  *
  * This method allocates an SSL domain object.  This object is used to hold 
the SSL

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2794da59/proton-c/src/ssl/openssl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/ssl/openssl.c b/proton-c/src/ssl/openssl.c
index ea2bd5b..dd1b88b 100644
--- a/proton-c/src/ssl/openssl.c
+++ b/proton-c/src/ssl/openssl.c
@@ -434,6 +434,11 @@ static void ssl_session_free( pn_ssl_session_t *ssn)
 
 /** Public API - visible to application code */
 
+bool pn_ssl_present(void)
+{
+  return true;
+}
+
 pn_ssl_domain_t *pn_ssl_domain( pn_ssl_mode_t mode )
 {
   if (!ssl_initialized) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2794da59/proton-c/src/ssl/ssl_stub.c
----------------------------------------------------------------------
diff --git a/proton-c/src/ssl/ssl_stub.c b/proton-c/src/ssl/ssl_stub.c
index 300215a..a5fce02 100644
--- a/proton-c/src/ssl/ssl_stub.c
+++ b/proton-c/src/ssl/ssl_stub.c
@@ -31,6 +31,11 @@
  * used if there is no SSL/TLS support in the system's environment.
  */
 
+bool pn_ssl_present(void)
+{
+  return false;
+}
+
 pn_ssl_t *pn_ssl(pn_transport_t *transport)
 {
   return NULL;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2794da59/proton-c/src/windows/schannel.c
----------------------------------------------------------------------
diff --git a/proton-c/src/windows/schannel.c b/proton-c/src/windows/schannel.c
index 9437582..de6e117 100644
--- a/proton-c/src/windows/schannel.c
+++ b/proton-c/src/windows/schannel.c
@@ -252,10 +252,13 @@ static void ssl_session_free( pn_ssl_session_t *ssn)
 
 /** Public API - visible to application code */
 
+bool pn_ssl_present(void)
+{
+  return false;
+}
+
 pn_ssl_domain_t *pn_ssl_domain( pn_ssl_mode_t mode )
 {
-  if (mode == PN_SSL_MODE_SERVER)
-    return NULL;  // Temporary: not ready for ctest, hide from isSSLPresent()
   pn_ssl_domain_t *domain = (pn_ssl_domain_t *) calloc(1, 
sizeof(pn_ssl_domain_t));
   if (!domain) return NULL;
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2794da59/proton-j/src/main/resources/cssl.py
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/cssl.py 
b/proton-j/src/main/resources/cssl.py
index 97740e3..74497ef 100644
--- a/proton-j/src/main/resources/cssl.py
+++ b/proton-j/src/main/resources/cssl.py
@@ -44,6 +44,9 @@ PN_SSL_MODE_P2J = {
   PN_SSL_MODE_SERVER: SslDomain.Mode.SERVER
 }
 
+def pn_ssl_present():
+  return True
+
 def pn_ssl_domain(mode):
   domain = Proton.sslDomain()
   domain.init(PN_SSL_MODE_P2J[mode])

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2794da59/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py 
b/tests/python/proton_tests/common.py
index cfb7e3d..e0887e6 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -22,8 +22,7 @@ from threading import Thread
 from socket import socket, AF_INET, SOCK_STREAM
 from subprocess import Popen,PIPE,STDOUT
 import sys, os, string
-from proton import Driver, Connection, Transport, SASL, Endpoint, Delivery, \
-    SSLDomain, SSLUnavailable
+from proton import Driver, Connection, Transport, SASL, Endpoint, Delivery, SSL
 
 
 def free_tcp_ports(count=1):
@@ -79,14 +78,7 @@ def pump(transport1, transport2, buffer_size=1024):
     pass
 
 def isSSLPresent():
-    """ True if a suitable SSL library is available.
-    """
-    try:
-        xxx = SSLDomain(SSLDomain.MODE_SERVER)
-        return True
-    except SSLUnavailable, e:
-        # SSL libraries not installed
-        return False
+    return SSL.present()
 
 class Test(object):
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to