OLD | NEW |
| (Empty) |
1 diff -aurb tlslite-0.3.8/tlslite/X509.py chromium/tlslite/X509.py | |
2 --- tlslite-0.3.8/tlslite/X509.py Fri Mar 19 18:43:19 2004 | |
3 +++ chromium/tlslite/X509.py Wed Feb 29 11:53:54 2012 | |
4 @@ -91,6 +91,7 @@ | |
5 | |
6 #Create a public key instance | |
7 self.publicKey = _createPublicRSAKey(n, e) | |
8 + return self | |
9 | |
10 def getFingerprint(self): | |
11 """Get the hex-encoded fingerprint of this certificate. | |
12 diff -aurb tlslite-0.3.8/tlslite/X509CertChain.py chromium/tlslite/X509CertChain
.py | |
13 --- tlslite-0.3.8/tlslite/X509CertChain.py Fri Mar 19 18:49:58 2004 | |
14 +++ chromium/tlslite/X509CertChain.py Wed Feb 29 11:53:42 2012 | |
15 @@ -1,6 +1,7 @@ | |
16 """Class representing an X.509 certificate chain.""" | |
17 | |
18 from utils import cryptomath | |
19 +from X509 import X509 | |
20 | |
21 class X509CertChain: | |
22 """This class represents a chain of X.509 certificates. | |
23 @@ -23,6 +24,66 @@ | |
24 self.x509List = x509List | |
25 else: | |
26 self.x509List = [] | |
27 + | |
28 + def parseChain(self, s): | |
29 + """Parse a PEM-encoded X.509 certificate file chain file. | |
30 + | |
31 + @type s: str | |
32 + @param s: A PEM-encoded (eg: Base64) X.509 certificate file, with every | |
33 + certificate wrapped within "-----BEGIN CERTIFICATE-----" and | |
34 + "-----END CERTIFICATE-----" tags). Extraneous data outside such tags, | |
35 + such as human readable representations, will be ignored. | |
36 + """ | |
37 + | |
38 + class PEMIterator(object): | |
39 + """Simple iterator over PEM-encoded certificates within a string. | |
40 + | |
41 + @type data: string | |
42 + @ivar data: A string containing PEM-encoded (Base64) certificates, | |
43 + with every certificate wrapped within "-----BEGIN CERTIFICATE-----" | |
44 + and "-----END CERTIFICATE-----" tags). Extraneous data outside such | |
45 + tags, such as human readable representations, will be ignored. | |
46 + | |
47 + @type index: integer | |
48 + @ivar index: The current offset within data to begin iterating from
. | |
49 + """ | |
50 + | |
51 + _CERTIFICATE_HEADER = "----BEGIN CERTIFICATE-----" | |
52 + """The PEM encoding block header for X.509 certificates.""" | |
53 + | |
54 + _CERTIFICATE_FOOTER = "----END CERTIFICATE-----" | |
55 + """The PEM encoding block footer for X.509 certificates.""" | |
56 + | |
57 + def __init__(self, s): | |
58 + self.data = s | |
59 + self.index = 0 | |
60 + | |
61 + def __iter__(self): | |
62 + return self | |
63 + | |
64 + def next(self): | |
65 + """Iterates and returns the next L{tlslite.X509.X509} | |
66 + certificate in data. | |
67 + | |
68 + @rtype tlslite.X509.X509 | |
69 + """ | |
70 + | |
71 + self.index = self.data.find(self._CERTIFICATE_HEADER, | |
72 + self.index) | |
73 + if self.index == -1: | |
74 + raise StopIteration | |
75 + end = self.data.find(self._CERTIFICATE_FOOTER, self.index) | |
76 + if end == -1: | |
77 + raise StopIteration | |
78 + | |
79 + certStr = self.data[self.index+len(self._CERTIFICATE_HEADER) : | |
80 + end] | |
81 + self.index = end + len(self._CERTIFICATE_FOOTER) | |
82 + bytes = cryptomath.base64ToBytes(certStr) | |
83 + return X509().parseBinary(bytes) | |
84 + | |
85 + self.x509List = list(PEMIterator(s)) | |
86 + return self | |
87 | |
88 def getNumCerts(self): | |
89 """Get the number of certificates in this chain. | |
OLD | NEW |