summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Pudeyev <p@users.noreply.github.com>2020-08-06 18:13:20 -0400
committerGitHub <noreply@github.com>2020-08-06 18:13:20 -0400
commitb4db913ecdc59a84c334a8b3503a25c16bb40b22 (patch)
tree511a2bab155359a7ab250733150e103948c4a327
parent89b1e50c154d8957a0a262f02ce45daa46250ff7 (diff)
parentf1e52365f65d6bf831cb0ab372020548bd9bbbe0 (diff)
downloadpycurl-b4db913ecdc59a84c334a8b3503a25c16bb40b22.tar.gz
Merge pull request #644 from swt2c/use_ssl_backends
Implement SSL backend detection using curl-config --ssl-backends
-rw-r--r--setup.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index b82d654..e41efb8 100644
--- a/setup.py
+++ b/setup.py
@@ -182,6 +182,9 @@ class ExtensionConfiguration(object):
ssl_lib_detected = self.detect_ssl_lib_from_libcurl_dll(libcurl_dll_path)
if not ssl_lib_detected:
+ ssl_lib_detected = self.detect_ssl_lib_using_curl_config()
+
+ if not ssl_lib_detected:
# self.sslhintbuf is a hack
for arg in split_quoted(self.sslhintbuf):
if arg[:2] == "-l":
@@ -386,6 +389,29 @@ manually. For other SSL backends please ignore this message.''')
print('libcurl_dll_path = "%s"' % libcurl_dll_path)
return self.detect_ssl_lib_from_libcurl_dll(libcurl_dll_path)
+ def detect_ssl_lib_using_curl_config(self):
+ ssl_lib_detected = None
+ p = subprocess.Popen((self.curl_config(), '--ssl-backends'),
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ if p.wait() != 0:
+ # curl-config --ssl-backends is not supported on older curl versions
+ return None
+ ssl_version = stdout.decode()
+ if ssl_version.startswith('OpenSSL') or ssl_version.startswith('LibreSSL'):
+ self.using_openssl()
+ ssl_lib_detected = 'openssl'
+ elif ssl_version.startswith('GnuTLS'):
+ self.using_gnutls()
+ ssl_lib_detected = 'gnutls'
+ elif ssl_version.startswith('NSS'):
+ self.using_nss()
+ ssl_lib_detected = 'nss'
+ elif ssl_version.startswith('mbedTLS'):
+ self.using_mbedtls()
+ ssl_lib_detected = 'mbedtls'
+ return ssl_lib_detected
+
def configure_windows(self):
# Windows users have to pass --curl-dir parameter to specify path
# to libcurl, because there is no curl-config on windows at all.