aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/ocsp.cpp
blob: 81cfa198bbb66083bd70e7ddd07bbc34db2ce581 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <botan/botan.h>
#include <botan/x509cert.h>
#include <botan/certstor.h>
#include <botan/x509path.h>
#include <botan/ocsp.h>

#include <iostream>

using namespace Botan;

int main(int argc, char* argv[])
   {
   if(argc != 2)
      std::cout << "Usage: ocsp subject.pem issuer.pem";

   X509_Certificate subject(argv[1]);
   X509_Certificate issuer(argv[2]);

   Certificate_Store_In_Memory cas;
   cas.add_certificate(issuer);
   OCSP::Response resp = OCSP::online_check(issuer, subject, &cas);

   auto status = resp.status_for(issuer, subject);

   if(status == Certificate_Status_Code::VERIFIED)
      std::cout << "OCSP check OK\n";
   else
      std::cout << "OCSP check failed " << Path_Validation_Result::status_string(status) << "\n";
   }