8000 Supply our own cert file · jkzilla/twilio-python@cc465b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit cc465b5

Browse files
author
Kevin Burke
committed
Supply our own cert file
1 parent 75a1983 commit cc465b5

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed

twilio/conf/cacert.pem

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
##
2+
## ca-bundle.crt -- Bundle of CA Root Certificates
3+
##
4+
## Certificate data from Mozilla as of: Thu Nov 3 19:04:19 2011
5+
##
6+
## This is a bundle of X.509 certificates of public Certificate Authorities
7+
## (CA). These were automatically extracted from Mozilla's root certificates
8+
## file (certdata.txt). This file can be found in the mozilla source tree:
9+
## http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1
10+
##
11+
## It contains the certificates in PEM format and therefore
12+
## can be directly used with curl / libcurl / php_curl, or with
13+
## an Apache+mod_ssl webserver for SSL client authentication.
14+
## Just configure this file as the SSLCACertificateFile.
15+
##
16+
17+
# ***** BEGIN LICENSE BLOCK *****
18+
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
19+
#
20+
# The contents of this file are subject to the Mozilla Public License Version
21+
# 1.1 (the "License"); you may not use this file except in compliance with
22+
# the License. You may obtain a copy of the License at
23+
# http://www.mozilla.org/MPL/
24+
#
25+
# Software distributed under the License is distributed on an "AS IS" basis,
26+
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
27+
# for the specific language governing rights and limitations under the
28+
# License.
29+
#
30+
# The Original Code is the Netscape security libraries.
31+
#
32+
# The Initial Developer of the Original Code is
33+
# Netscape Communications Corporation.
34+
# Portions created by the Initial Developer are Copyright (C) 1994-2000
35+
# the Initial Developer. All Rights Reserved.
36+
#
37+
# Contributor(s):
38+
#
39+
# Alternatively, the contents of this file may be used under the terms of
40+
# either the GNU General Public License Version 2 or later (the "GPL"), or
41+
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
42+
# in which case the provisions of the GPL or the LGPL are applicable instead
43+
# of those above. If you wish to allow use of your version of this file only
44+
# under the terms of either the GPL or the LGPL, and not to allow others to
45+
# use your version of this file under the terms of the MPL, indicate your
46+
# decision by deleting the provisions above and replace them with the notice
47+
# and other provisions required by the GPL or the LGPL. If you do not delete
48+
# the provisions above, a recipient may use your version of this file under
49+
# the terms of any one of the MPL, the GPL or the LGPL.
50+
#
51+
# ***** END LICENSE BLOCK *****
52+
# @(#) $RCSfile: certdata.txt,v $ $Revision: 1.80 $ $Date: 2011/11/03 15:11:58 $
53+
54+
GTE CyberTrust Global Root
55+
==========================
56+
-----BEGIN CERTIFICATE-----
57+
MIICWjCCAcMCAgGlMA0GCSqGSIb3DQEBBAUAMHUxCzAJBgNVBAYTAlVTMRgwFgYDVQQKEw9HVEUg
58+
Q29ycG9yYXRpb24xJzAlBgNVBAsTHkdURSBDeWJlclRydXN0IFNvbHV0aW9ucywgSW5jLjEjMCEG
59+
A1UEAxMaR1RFIEN5YmVyVHJ1c3QgR2xvYmFsIFJvb3QwHhcNOTgwODEzMDAyOTAwWhcNMTgwODEz
60+
MjM1OTAwWjB1MQswCQYDVQQGEwJVUzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQL
61+
Ex5HVEUgQ3liZXJUcnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0
62+
IEdsb2JhbCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVD6C28FCc6HrHiM3dFw4u
63+
sJTQGz0O9pTAipTHBsiQl8i4ZBp6fmw8U+E3KHNgf7KXUwefU/ltWJTSr41tiGeA5u2ylc9yMcql
64+
HHK6XALnZELn+aks1joNrI1CqiQBOeacPwGFVw1Yh0X404Wqk2kmhXBIgD8SFcd5tB8FLztimQID
65+
AQABMA0GCSqGSIb3DQEBBAUAA4GBAG3rGwnpXtlR22ciYaQqPEh346B8pt5zohQDhT37qw4wxYMW
66+
M4ETCJ57NE7fQMh017l93PR2VX2bY1QY6fDq81yx2YtCHrnAlU66+tXifPVoYb+O7AWXX1uw16OF
67+
NMQkpw0PlZPvy5TYnh+dXIVtx6quTx8itc2VrbqnzPmrC3p/
68+
-----END CERTIFICATE-----
69+

twilio/rest/resources/base.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
from six import integer_types, string_types, binary_type, iteritems
34
from twilio.compat import urlparse
45
from twilio.compat import urlencode
@@ -21,6 +22,19 @@ def __init__(self, httplib_resp, content, url):
2122
self.ok = self.status_code < 400
2223
self.url = url
2324

25+
def get_cert_file():
26+
""" Get the cert file location or bail """
27+
try:
28+
# Apparently __file__ is not available in all places so wrapping this in
29+
# a try/catch
30+
current_path = os.path.realpath(__file__)
31+
ca_cert_path = os.path.join(current_path, "..", "..", "..",
32+
"conf", "cacert.pem")
33+
return os.path.abspath(ca_cert_path)
34+
except Exception:
35+
# None means use the default system file
36+
return None
37+
2438

2539
def make_request(method, url, params=None, data=None, headers=None,
2640
cookies=None, files=None, auth=None, timeout=None,
@@ -31,7 +45,7 @@ def make_request(method, url, params=None, data=None, headers=None,
3145
3246
Currently proxies, files, and cookies are all ignored
3347
"""
34-
http = httplib2.Http(timeout=timeout)
48+
http = httplib2.Http(timeout=timeout, ca_certs=get_cert_file())
3549
http.follow_redirects = allow_redirects
3650

3751
if auth is not None:

0 commit comments

Comments
 (0)
0