diff options
author | lloyd <[email protected]> | 2014-01-10 00:08:13 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-01-10 00:08:13 +0000 |
commit | 57789bdfc55061002b2727d0b32587612829a37c (patch) | |
tree | 99f36631b4ec50c5187a1b0a7c256b99182373ad /src/cmd/cert_verify.cpp | |
parent | 94968c917407a63d888fd3eb4d02491f60de6ebc (diff) |
Split up test vectors into per-algo files and app into botan-test for
the tests and botan for everything else.
Diffstat (limited to 'src/cmd/cert_verify.cpp')
-rw-r--r-- | src/cmd/cert_verify.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/cmd/cert_verify.cpp b/src/cmd/cert_verify.cpp new file mode 100644 index 000000000..154267fe1 --- /dev/null +++ b/src/cmd/cert_verify.cpp @@ -0,0 +1,43 @@ +/* +* Simple example of a certificate validation +* (C) 2010 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include "apps.h" +#include <botan/x509cert.h> +#include <botan/x509path.h> +#include <iostream> + +using namespace Botan; + +int cert_verify_main(int argc, char* argv[]) + { + if(argc <= 2) + { + std::cout << "Usage: " << argv[0] << " subject.pem [CA certificates...]\n"; + return 1; + } + + X509_Certificate subject_cert(argv[1]); + + Certificate_Store_In_Memory certs; + + for(size_t i = 2; argv[i]; ++i) + certs.add_certificate(X509_Certificate(argv[i])); + + Path_Validation_Restrictions restrictions; + + Path_Validation_Result result = + x509_path_validate(subject_cert, + restrictions, + certs); + + if(result.successful_validation()) + std::cout << "Certificate validated\n"; + else + std::cout << "Certificate did not validate - " << result.result_string() << "\n"; + + return 0; + } |