| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import asn1 | 5 import asn1 |
| 6 import hashlib | 6 import hashlib |
| 7 import os | 7 import os |
| 8 | 8 |
| 9 | 9 |
| 10 # This file implements very minimal certificate and OCSP generation. It's | 10 # This file implements very minimal certificate and OCSP generation. It's |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 def GenerateCertKeyAndOCSP(subject = "127.0.0.1", | 311 def GenerateCertKeyAndOCSP(subject = "127.0.0.1", |
| 312 ocsp_url = "http://127.0.0.1", | 312 ocsp_url = "http://127.0.0.1", |
| 313 ocsp_revoked = False): | 313 ocsp_revoked = False): |
| 314 '''GenerateCertKeyAndOCSP returns a (cert_and_key_pem, ocsp_der) where: | 314 '''GenerateCertKeyAndOCSP returns a (cert_and_key_pem, ocsp_der) where: |
| 315 * cert_and_key_pem contains a certificate and private key in PEM format | 315 * cert_and_key_pem contains a certificate and private key in PEM format |
| 316 with the given subject common name and OCSP URL. | 316 with the given subject common name and OCSP URL. |
| 317 * ocsp_der contains a DER encoded OCSP response or None if ocsp_url is | 317 * ocsp_der contains a DER encoded OCSP response or None if ocsp_url is |
| 318 None''' | 318 None''' |
| 319 | 319 |
| 320 serial = RandomNumber(16) | 320 serial = RandomNumber(16) |
| 321 cert_der = MakeCertificate(ISSUER_CN, subject, serial, KEY, KEY, ocsp_url) | 321 cert_der = MakeCertificate(ISSUER_CN, bytes(subject), serial, KEY, KEY, |
| 322 bytes(ocsp_url)) |
| 322 cert_pem = DERToPEM(cert_der) | 323 cert_pem = DERToPEM(cert_der) |
| 323 | 324 |
| 324 ocsp_der = None | 325 ocsp_der = None |
| 325 if ocsp_url is not None: | 326 if ocsp_url is not None: |
| 326 ocsp_der = MakeOCSPResponse(ISSUER_CN, KEY, serial, ocsp_revoked) | 327 ocsp_der = MakeOCSPResponse(ISSUER_CN, KEY, serial, ocsp_revoked) |
| 327 | 328 |
| 328 return (cert_pem + KEY_PEM, ocsp_der) | 329 return (cert_pem + KEY_PEM, ocsp_der) |
| OLD | NEW |