aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/x509info.cpp
blob: b22b4ebd89ffe8082dd590ebca57039574247bc3 (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
30
31
32
33
34
35
/*
* Read an X.509 certificate, and print various things about it
* (C) 2003 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/

#include <botan/botan.h>
#include <botan/x509cert.h>
using namespace Botan;

#include <iostream>

int main(int argc, char* argv[])
   {
   if(argc != 2)
      {
      std::cout << "Usage: " << argv[0] << " <x509cert>\n";
      return 1;
      }

   Botan::LibraryInitializer init;

   try {
      X509_Certificate cert(argv[1]);

      std::cout << cert.to_string();
   }
   catch(std::exception& e)
      {
      std::cout << e.what() << std::endl;
      return 1;
      }
   return 0;
   }