diff options
author | Jack Lloyd <[email protected]> | 2016-02-21 12:48:16 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-02-21 12:48:16 -0500 |
commit | 0a9505a067313e0e1b9099873642e07ad9fee52f (patch) | |
tree | e4ff59dd1c75f25f98442cbec9a5d9db71ff8810 /src/lib | |
parent | 410474253fd491c21c4a69d1352325136416d675 (diff) | |
parent | 5c6373a7a595b396b0a4ead0a7ff277762f4b2a0 (diff) |
Merge pull request #431 from cordney/python-improvements
Improvements in X.509 cert handling for python bindings. Add Python code coverage report.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/ffi/ffi.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp index c5decdcf2..621195ea3 100644 --- a/src/lib/ffi/ffi.cpp +++ b/src/lib/ffi/ffi.cpp @@ -1310,8 +1310,27 @@ int botan_x509_cert_path_verify(botan_x509_cert_t cert, const char* dir) int botan_x509_cert_get_public_key(botan_x509_cert_t cert, botan_pubkey_t* key) { + try + { + if(key == nullptr) + return -1; + + *key = nullptr; + +#if defined(BOTAN_HAS_RSA) + std::unique_ptr<Botan::Public_Key> publicKey(safe_get(cert).subject_public_key()); + *key = new botan_pubkey_struct(publicKey.release()); + return 0; +#else return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; - //return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { return write_vec_output(out, out_len, cert.subject_public_key_bits()); }); +#endif + } + catch(std::exception& e) + { + log_exception(BOTAN_CURRENT_FUNCTION, e.what()); + } + + return BOTAN_FFI_ERROR_EXCEPTION_THROWN; } int botan_x509_cert_get_issuer_dn(botan_x509_cert_t cert, |