diff options
author | René Korthaus <[email protected]> | 2016-02-20 20:03:20 +0100 |
---|---|---|
committer | René Korthaus <[email protected]> | 2016-02-20 20:03:47 +0100 |
commit | 8928c29564a9dc3f54542108530ff3cb62396124 (patch) | |
tree | 888b4f77fd6570c426dbfa1318e30cb3f50bb2b1 /src/lib/ffi | |
parent | f794b638a4059d3c004f092b6bd89d27cf4ffefa (diff) |
Improvements in X.509 cert handling for python bindings
Add implementation for ffi botan_x509_cert_get_public_key().
Add subject_dn() function to python x509_cert class.
Have python x509_cert constructor take a buffer alternatively.
Have python x509_cert functions time_starts() and time_expires() return
a python timestamp.
Diffstat (limited to 'src/lib/ffi')
-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, |