xrootd
XrdCryptosslX509.hh
Go to the documentation of this file.
1 // $Id$
2 #ifndef __CRYPTO_SSLX509_H__
3 #define __CRYPTO_SSLX509_H__
4 /******************************************************************************/
5 /* */
6 /* X r d C r y p t o s s l X 5 0 9 . h h */
7 /* */
8 /* */
9 /* (c) 2005 G. Ganis , CERN */
10 /* */
11 /******************************************************************************/
12 
13 /* ************************************************************************** */
14 /* */
15 /* OpenSSL implementation of XrdCryptoX509 */
16 /* */
17 /* ************************************************************************** */
18 
20 
21 #include <openssl/x509v3.h>
22 #include <openssl/bio.h>
23 #include <openssl/evp.h>
24 
25 // ---------------------------------------------------------------------------//
26 //
27 // OpenSSL X509 implementation
28 //
29 // ---------------------------------------------------------------------------//
31 {
32 
33 public:
34  XrdCryptosslX509(const char *cf, const char *kf = 0);
36  XrdCryptosslX509(X509 *cert);
37  virtual ~XrdCryptosslX509();
38 
39  // Access underlying data (in opaque form: used in chains)
41 
42  // Access certificate key
43  XrdCryptoRSA *PKI() { return pki; }
45 
46  // Export in form of bucket (for transfers)
48 
49  // Parent file
50  const char *ParentFile() { return (const char *)(srcfile.c_str()); }
51 
52  // Key strength
53  int BitStrength() { return ((cert) ? EVP_PKEY_bits(X509_get_pubkey(cert)) : -1);}
54 
55  // Serial number
58 
59  // Validity
60  int NotBefore(); // get begin-validity time in secs since Epoch
61  int NotAfter(); // get end-validity time in secs since Epoch
62 
63  // Relevant Names
64  const char *Subject(); // get subject name
65  const char *Issuer(); // get issuer name
66 
67  // Relevant hashes
68  const char *SubjectHash(); // get hash of subject name
69  const char *IssuerHash(); // get hash of issuer name
70 
71  // Retrieve a given extension if there (in opaque form)
72  XrdCryptoX509data GetExtension(const char *oid);
73 
74  // Verify signature
75  bool Verify(XrdCryptoX509 *ref);
76 
77 private:
78  X509 *cert; // The certificate object
79  int notbefore; // begin-validity time in secs since Epoch
80  int notafter; // end-validity time in secs since Epoch
81  XrdOucString subject; // subject;
82  XrdOucString issuer; // issuer name;
83  XrdOucString subjecthash; // hash of subject;
84  XrdOucString issuerhash; // hash of issuer name;
85  XrdOucString srcfile; // source file name, if any;
86  XrdSutBucket *bucket; // Bucket for export operations
87  XrdCryptoRSA *pki; // PKI of the certificate
88 
89  bool IsCA(); // Find out if we are a CA
90 
91 };
92 
93 #endif