| OLD | NEW |
| 1 # Copyright 2015 Google Inc. All rights reserved. | 1 # Copyright 2015 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 key: string, private key in PEM format. | 108 key: string, private key in PEM format. |
| 109 password: string, password for private key file. Unused for PEM | 109 password: string, password for private key file. Unused for PEM |
| 110 files. | 110 files. |
| 111 | 111 |
| 112 Returns: | 112 Returns: |
| 113 Signer instance. | 113 Signer instance. |
| 114 | 114 |
| 115 Raises: | 115 Raises: |
| 116 NotImplementedError if the key isn't in PEM format. | 116 NotImplementedError if the key isn't in PEM format. |
| 117 """ | 117 """ |
| 118 parsed_pem_key = _parse_pem_key(key) | 118 parsed_pem_key = _parse_pem_key(_to_bytes(key)) |
| 119 if parsed_pem_key: | 119 if parsed_pem_key: |
| 120 pkey = RSA.importKey(parsed_pem_key) | 120 pkey = RSA.importKey(parsed_pem_key) |
| 121 else: | 121 else: |
| 122 raise NotImplementedError( | 122 raise NotImplementedError( |
| 123 'PKCS12 format is not supported by the PyCrypto library. ' | 123 'No key in PEM format was detected. This implementation ' |
| 124 'Try converting to a "PEM" ' | 124 'can only use the PyCrypto library for keys in PEM ' |
| 125 '(openssl pkcs12 -in xxxxx.p12 -nodes -nocerts > ' | 125 'format.') |
| 126 'privatekey.pem) ' | |
| 127 'or using PyOpenSSL if native code is an option.') | |
| 128 return PyCryptoSigner(pkey) | 126 return PyCryptoSigner(pkey) |
| OLD | NEW |