aboutsummaryrefslogtreecommitdiff
path: root/wraptool.py
diff options
context:
space:
mode:
Diffstat (limited to 'wraptool.py')
-rwxr-xr-xwraptool.py65
1 files changed, 15 insertions, 50 deletions
diff --git a/wraptool.py b/wraptool.py
index ecb2899..2366b78 100755
--- a/wraptool.py
+++ b/wraptool.py
@@ -20,11 +20,6 @@ import configparser
import shutil
import platform
try:
- # FIXME for some unknown reason ssl connections
- # fail on OSX. Thus fall back to unencrypted
- # traffic.
- if platform.system().lower() == 'darwin':
- import nonexisting
import ssl
has_ssl = True
API_ROOT = 'https://wrapdb.mesonbuild.com/v1/'
@@ -37,40 +32,6 @@ ssl_warning_printed = False
from glob import glob
-wrapdb_certificate = '''-----BEGIN CERTIFICATE-----
-MIIFkzCCA3ugAwIBAgIJAIjVMWLmbJWUMA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV
-BAYTAkZJMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxGjAYBgNVBAoMEVRoZSBNZXNv
-biBQcm9qZWN0MR4wHAYDVQQDDBV3cmFwZGIubWVzb25idWlsZC5jb20wHhcNMTUw
-NzIxMTk0NjI1WhcNMTYwNzIwMTk0NjI1WjBgMQswCQYDVQQGEwJGSTEVMBMGA1UE
-BwwMRGVmYXVsdCBDaXR5MRowGAYDVQQKDBFUaGUgTWVzb24gUHJvamVjdDEeMBwG
-A1UEAwwVd3JhcGRiLm1lc29uYnVpbGQuY29tMIICIjANBgkqhkiG9w0BAQEFAAOC
-Ag8AMIICCgKCAgEArucsF2GNXW6PqGlW3egD3LxIX+YTWc7MscM5MFryoQEdCsxm
-ME50J2bKZxyJIO+0bCyjvGQNbQxNIvu03ftMYVvbr949km+qafFy63U+QISXOdK1
-oAPIeQnxjwTt+xK/2E8NjChQeWMOb6iX0hsxRtBWoL35SP541xGjgjWKOJTErqcV
-YdDiiTaChZMb9oV4qNEipBKHvU0EmLsF1Lm8psw332QlR5eqmCk12LtV7l5kVH38
-XD+aDpuB5CajcWdEQMDk4rDW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35gn1yp/Vw2O7Vk+E7m
-SuYF28YTKF/woZWdJH1aQDO0erUBXdiycZVeKbdm3jenNPHTiF/Wt22CXIlGjj83
-G+eGrvfQVk3oXRn+YlypIbxkV8eI1wOina799oiflQmvV8EevAS4dkJObahV6rtZ
-qf3ZjWGS595JCwW0fq6AAtL+ygMSr6+DcjGibYbWTL3GmiMtUeWr
------END CERTIFICATE-----
-'''
-
help_templ = '''This program allows you to manage your Wrap dependencies
using the online wrap database http://wrapdb.mesonbuild.com.
@@ -100,23 +61,27 @@ def build_ssl_context():
ctx.options |= ssl.OP_NO_SSLv2
ctx.options |= ssl.OP_NO_SSLv3
ctx.verify_mode = ssl.CERT_REQUIRED
- ctx.load_verify_locations(cadata=wrapdb_certificate)
+ ctx.load_default_certs()
return ctx
def open_wrapdburl(urlstring):
global ssl_warning_printed
if has_ssl:
- return urllib.request.urlopen(urlstring, context=build_ssl_context())
- else:
- if not ssl_warning_printed:
- print('Warning: ssl not available, traffic not authenticated.',
- file=sys.stderr)
- ssl_warning_printed = True
- # Trying to open SSL connection to wrapdb fails because the
- # certificate is not known. Use plain http. For some
- # reason OSX fails here again.
+ try:
+ return urllib.request.urlopen(urlstring)#, context=build_ssl_context())
+ except urllib.error.URLError:
+ if not ssl_warning_printed:
+ print('SSL connection failed. Falling back to unencrypted connections.')
+ ssl_warning_printed = True
+ if not ssl_warning_printed:
+ print('Warning: SSL not available, traffic not authenticated.',
+ file=sys.stderr)
+ ssl_warning_printed = True
+ # Trying to open SSL connection to wrapdb fails because the
+ # certificate is not known.
+ if urlstring.startswith('https'):
urlstring = 'http' + urlstring[5:]
- return urllib.request.urlopen(urlstring)
+ return urllib.request.urlopen(urlstring)
def get_result(urlstring):
u = open_wrapdburl(urlstring)