aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-02 05:08:15 +0000
committerlloyd <[email protected]>2010-03-02 05:08:15 +0000
commit3c15bd259f0921f1fa08ec91ee3cf2621c64a02d (patch)
tree54351d5e865a872896c6a95175693cc0ffa9e246 /doc/examples
parent5fec937bd0c72858d6cf2f09b58b219294c7d5cc (diff)
parent54a3c5ae67f8b987d05ffd18e2d49a2da1d5988e (diff)
propagate from branch 'net.randombit.botan' (head fc86fc4842254088bf820ea6ebf05877aa63fb22)
to branch 'net.randombit.botan.c++0x' (head 77565ff7252df7f8faad86d65075498b0adb93d8)
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/cert_verify.cpp35
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;
+ }