Skip to content

Commit a08a1f7

Browse files
committed
* Added AnotherName attribute for subjectAltNames
* fix to command line utility HTTP Basic Auth support.
1 parent 7ec8874 commit a08a1f7

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

ndg/httpsclient/subj_alt_name.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,21 @@ class Extensions(univ.SequenceOf):
9999
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
100100

101101

102+
class AnotherName(univ.Sequence):
103+
componentType = namedtype.NamedTypes(
104+
namedtype.NamedType('type-id', univ.ObjectIdentifier()),
105+
namedtype.NamedType('value', univ.Any().subtype(
106+
explicitTag=tag.Tag(tag.tagClassContext,
107+
tag.tagFormatSimple, 0))
108+
)
109+
110+
102111
class GeneralName(univ.Choice):
103112
'''ASN.1 configuration for X.509 certificate subjectAltNames fields'''
104113
componentType = namedtype.NamedTypes(
105-
# namedtype.NamedType('otherName', AnotherName().subtype(
106-
# implicitTag=tag.Tag(tag.tagClassContext,
107-
# tag.tagFormatSimple, 0))),
114+
namedtype.NamedType('otherName', AnotherName().subtype(
115+
implicitTag=tag.Tag(tag.tagClassContext,
116+
tag.tagFormatSimple, 0))),
108117
namedtype.NamedType('rfc822Name', char.IA5String().subtype(
109118
implicitTag=tag.Tag(tag.tagClassContext,
110119
tag.tagFormatSimple, 1))),

ndg/httpsclient/test/test_urllib2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ def test04_open_peer_cert_verification_fails(self):
4747

4848

4949
if __name__ == "__main__":
50-
unittest.main()
50+
unittest.main()

ndg/httpsclient/utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ def fetch_from_url_to_file(url, config, output_file, data=None, handlers=None):
101101
outfile = open(output_file, "w")
102102
outfile.write(return_data)
103103
outfile.close()
104+
104105
return return_code, return_message, return_code == httplib.OK
105106

107+
106108
def fetch_stream_from_url(url, config, data=None, handlers=None):
107109
"""Returns data retrieved from a URL.
108110
@param url: URL to attempt to open
@@ -202,16 +204,19 @@ def open_url(url, config, data=None, handlers=None):
202204
if log.isEnabledFor(logging.DEBUG):
203205
for index, cookie in enumerate(cj):
204206
log.debug("%s : %s", index, cookie)
207+
205208
except urllib2.HTTPError, exc:
206209
return_code = exc.code
207210
return_message = "Error: %s" % exc.msg
208211
if log.isEnabledFor(logging.DEBUG):
209212
log.debug("%s %s", exc.code, exc.msg)
213+
210214
except Exception, exc:
211215
return_message = "Error: %s" % exc.__str__()
212216
if log.isEnabledFor(logging.DEBUG):
213217
import traceback
214218
log.debug(traceback.format_exc())
219+
215220
return (return_code, return_message, response)
216221

217222

@@ -305,7 +310,8 @@ def main():
305310
parser.add_option("-n", "--no-verify-peer", action="store_true",
306311
dest="no_verify_peer", default=False,
307312
help="Skip verification of peer certificate.")
308-
parser.add_option("-a", "--basicauth", dest="auth", metavar="USER:PASSWD",
313+
parser.add_option("-a", "--basicauth", dest="basicauth",
314+
metavar="USER:PASSWD",
309315
default=None,
310316
help="HTTP authentication credentials")
311317
parser.add_option("--header", action="append", dest="headers",
@@ -345,7 +351,7 @@ def main():
345351
data = None
346352

347353
if options.basicauth:
348-
http_basicauth = options.auth.split(':', 1)
354+
http_basicauth = options.basicauth.split(':', 1)
349355
else:
350356
http_basicauth = None
351357

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
1414
Releases
1515
========
16+
0.3.3
17+
-----
18+
* Fix to add in AnotherName for subjectAltNames field - added for support for CACert issued
19+
certs (thanks to Gu1).
20+
* Fix to HTTP Basic Auth option for ndg.httpsclient.utils.main
21+
1622
0.3.2
1723
-----
1824
* Fix to SubjectAltNames support check - should only be enabled if pyasn1 is
@@ -90,7 +96,7 @@
9096

9197
setup(
9298
name='ndg_httpsclient',
93-
version="0.3.2",
99+
version="0.3.3",
94100
description='Provides enhanced HTTPS support for httplib and urllib2 using '
95101
'PyOpenSSL',
96102
author='Richard Wilkinson and Philip Kershaw',

0 commit comments

Comments
 (0)