diff options
author | lloyd <[email protected]> | 2011-04-08 14:57:49 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-04-08 14:57:49 +0000 |
commit | fc62f7f284387a180e42402e8706965a666efba7 (patch) | |
tree | 9abe74c670993c111bd3a5bf5fb568767f9e75be /doc/examples/cert_verify.cpp | |
parent | 438f3eb73e494fcab82b239452d712bec06f48c9 (diff) |
More pubkey doc updates
Diffstat (limited to 'doc/examples/cert_verify.cpp')
-rw-r--r-- | doc/examples/cert_verify.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/doc/examples/cert_verify.cpp b/doc/examples/cert_verify.cpp new file mode 100644 index 000000000..04bcbecad --- /dev/null +++ b/doc/examples/cert_verify.cpp @@ -0,0 +1,35 @@ +/* +* Simple example of a certificate validation +* (C) 2010 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include <botan/botan.h> +#include <botan/x509cert.h> +#include <botan/x509stor.h> + +#include <stdio.h> + +using namespace Botan; + +int main() + { + LibraryInitializer init; + + X509_Certificate ca_cert("ca_cert.pem"); + X509_Certificate subject_cert("http_cert.pem"); + + X509_Store cert_store; + + cert_store.add_cert(ca_cert, /*trusted=*/true); + + X509_Code code = cert_store.validate_cert(subject_cert); + + if(code == VERIFIED) + printf("Cert validated\n"); + else + printf("Cert did not validate, code = %d\n", code); + + return 0; + } |