| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """An https server that forwards requests to another server. This allows a | 5 """An https server that forwards requests to another server. This allows a |
| 6 server that supports http only to be accessed over https. | 6 server that supports http only to be accessed over https. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 import BaseHTTPServer | 9 import BaseHTTPServer |
| 10 import os | 10 import os |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 """A multi-threaded version of testserver.HTTPSServer.""" | 77 """A multi-threaded version of testserver.HTTPSServer.""" |
| 78 | 78 |
| 79 def __init__(self, server_address, request_hander_class, pem_cert_and_key): | 79 def __init__(self, server_address, request_hander_class, pem_cert_and_key): |
| 80 """Initializes the server. | 80 """Initializes the server. |
| 81 | 81 |
| 82 Args: | 82 Args: |
| 83 server_address: Server host and port. | 83 server_address: Server host and port. |
| 84 request_hander_class: The class that will handle requests to the server. | 84 request_hander_class: The class that will handle requests to the server. |
| 85 pem_cert_and_key: Path to file containing the https cert and private key. | 85 pem_cert_and_key: Path to file containing the https cert and private key. |
| 86 """ | 86 """ |
| 87 self.cert_chain = tlslite.api.X509CertChain().parseChain(pem_cert_and_key) | 87 self.cert_chain = tlslite.api.X509CertChain() |
| 88 self.cert_chain.parsePemList(pem_cert_and_key) |
| 88 # Force using only python implementation - otherwise behavior is different | 89 # Force using only python implementation - otherwise behavior is different |
| 89 # depending on whether m2crypto Python module is present (error is thrown | 90 # depending on whether m2crypto Python module is present (error is thrown |
| 90 # when it is). m2crypto uses a C (based on OpenSSL) implementation under | 91 # when it is). m2crypto uses a C (based on OpenSSL) implementation under |
| 91 # the hood. | 92 # the hood. |
| 92 self.private_key = tlslite.api.parsePEMKey(pem_cert_and_key, | 93 self.private_key = tlslite.api.parsePEMKey(pem_cert_and_key, |
| 93 private=True, | 94 private=True, |
| 94 implementations=['python']) | 95 implementations=['python']) |
| 95 | 96 |
| 96 testserver_base.StoppableHTTPServer.__init__(self, | 97 testserver_base.StoppableHTTPServer.__init__(self, |
| 97 server_address, | 98 server_address, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 'only).') | 161 'only).') |
| 161 self.option_parser.add_option('--cert-and-key-file', help='The path to the ' | 162 self.option_parser.add_option('--cert-and-key-file', help='The path to the ' |
| 162 'file containing the certificate and private ' | 163 'file containing the certificate and private ' |
| 163 'key for the server in PEM format.') | 164 'key for the server in PEM format.') |
| 164 self.option_parser.add_option('--forward-target', help='The URL prefix to ' | 165 self.option_parser.add_option('--forward-target', help='The URL prefix to ' |
| 165 'which requests will be forwarded.') | 166 'which requests will be forwarded.') |
| 166 | 167 |
| 167 | 168 |
| 168 if __name__ == '__main__': | 169 if __name__ == '__main__': |
| 169 sys.exit(ServerRunner().main()) | 170 sys.exit(ServerRunner().main()) |
| OLD | NEW |