9void print_details(
WvX509 *x509)
12 wvcon->print(
"Issuer: %s\n", x509->
get_issuer());
13 wvcon->print(
"Serial: %s\n", x509->
get_serial());
15 time_t t2 = x509->get_notvalid_after();
17 wvcon->print(
"Not Valid Before: %s\n", ctime(&t1));
18 wvcon->print(
"Not Valid After: %s\n", ctime(&t2));
21 wvcon->print(
"Authority Info Access: \n%s\n", x509->
get_aia());
24 wvcon->print(
"CA Issuers available from:\n%s\n", list.
join(
"\n"));
27 wvcon->print(
"OCSP Responders available from:\n%s\n", list.
join(
"\n"));
30 wvcon->print(
"CRL Distribution Points:\n%s\n", list.
join(
"\n"));
33 wvcon->print(
"Certificate Policy OIDs:\n%s\n", list.
join(
"\n"));
35#ifdef HAVE_OPENSSL_POLICY_MAPPING
36 int requireExplicitPolicy, inhibitPolicyMapping;
38 wvcon->print(
"Certificate Policy Constraints: requireExplicitPolicy: %s "
39 "inhibitPolicyMapping: %s\n", requireExplicitPolicy,
40 inhibitPolicyMapping);
42 WvX509::PolicyMapList maplist;
44 wvcon->print(
"Policy mappings:\n");
45 WvX509::PolicyMapList::Iter i(maplist);
46 for (i.rewind(); i.next();)
47 wvcon->print(
"%s -> %s\n", i().issuer_domain, i().subject_domain);
52int main(
int argc,
char **argv)
54 wvcrash_setup(argv[0]);
61 args.
add_option(
't',
"type",
"Certificate type: der or pem (default: pem)",
63 if (!args.
process(argc, argv, &remaining_args) || remaining_args.count() < 1)
71 if (certtype ==
"der")
72 x509.load(WvX509Mgr::CertDER, remaining_args.
popstr());
73 else if (certtype ==
"pem")
74 x509.load(WvX509Mgr::CertPEM, remaining_args.
popstr());
77 wverr->print(
"Invalid certificate type '%s'\n", certtype);
84 wverr->print(
"X509 certificate not valid\n");
WvArgs - Sane command-line argument processing for WvStreams.
bool process(int argc, char **argv, WvStringList *remaining_args=NULL)
Process the command line arguments passed to main() using the options provided through calls to add_o...
void add_option(char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, int &val)
Add a switch that takes an integer argument.
void add_required_arg(WvStringParm desc, bool multiple=false)
Add a required argument to the list of parameters.
void print_help(int argc, char **argv)
Output the long usage message based on the provided options.
This is a WvList of WvStrings, and is a really handy way to parse strings.
WvString join(const char *joinchars=" ") const
concatenates all elements of the list seperating on joinchars
WvString popstr()
get the first string in the list, or an empty string if the list is empty.
WvString is an implementation of a simple and efficient printable-string class.
X509 Class to handle certificates and their related functions.
time_t get_notvalid_before() const
Return the not before and not after in a format we're more able to easily use.
WvString get_serial(bool hex=false) const
get and set the serialNumber field of the certificate
void get_ocsp(WvStringList &responders) const
Get a list of OCSP Responders for this certificate.
void get_ca_urls(WvStringList &urls) const
Get a list of urls that have the Certificate of the CA that issued this certificate.
bool get_policy_mapping(PolicyMapList &list) const
Get the policy mappings for this certificate.
WvString get_ext_key_usage() const
Get and set the extendedKeyUsage field.
bool get_policies(WvStringList &policy_oids) const
Get any certificate Policy OIDs.
WvString get_subject() const
get and set the Subject field of the certificate
bool get_policy_constraints(int &require_explicit_policy, int &inhibit_policy_mapping) const
Get the values in the policy constraints extension.
WvString get_issuer() const
Get and set the Certificate Issuer (usually the CA who signed the certificate).
WvString get_aia() const
Get the authority info access information.
WvString get_key_usage() const
Get and set the keyUsage field.
void get_crl_urls(WvStringList &urls) const
Get a list of URLs that are valid CRL distribution points for this certificate.
virtual bool isok() const
Is the certificate object valid?
Various little string functions.