XRootD
Loading...
Searching...
No Matches
XrdCryptosslX509.hh
Go to the documentation of this file.
1#ifndef __CRYPTO_SSLX509_H__
2#define __CRYPTO_SSLX509_H__
3/******************************************************************************/
4/* */
5/* X r d C r y p t o s s l X 5 0 9 . h h */
6/* */
7/* (c) 2005 G. Ganis , CERN */
8/* */
9/* This file is part of the XRootD software suite. */
10/* */
11/* XRootD is free software: you can redistribute it and/or modify it under */
12/* the terms of the GNU Lesser General Public License as published by the */
13/* Free Software Foundation, either version 3 of the License, or (at your */
14/* option) any later version. */
15/* */
16/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19/* License for more details. */
20/* */
21/* You should have received a copy of the GNU Lesser General Public License */
22/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24/* */
25/* The copyright holder's institutional names and contributor's names may not */
26/* be used to endorse or promote products derived from this software without */
27/* specific prior written permission of the institution or contributor. */
28/* */
29/******************************************************************************/
30
31/* ************************************************************************** */
32/* */
33/* OpenSSL implementation of XrdCryptoX509 */
34/* */
35/* ************************************************************************** */
36
38
39#include <openssl/x509v3.h>
40#include <openssl/bio.h>
41#include <openssl/evp.h>
42
43// ---------------------------------------------------------------------------//
44//
45// OpenSSL X509 implementation
46//
47// ---------------------------------------------------------------------------//
49{
50
51public:
52 XrdCryptosslX509(const char *cf, const char *kf = 0);
54 XrdCryptosslX509(X509 *cert);
55 virtual ~XrdCryptosslX509();
56
57 // Access underlying data (in opaque form: used in chains)
59
60 // Dump extensions
61 int DumpExtensions(bool dumpunknown = 0);
62
63 // Access certificate key
64 XrdCryptoRSA *PKI() { return pki; }
65 void SetPKI(XrdCryptoX509data pki);
66
67 // Export in form of bucket (for transfers)
69
70 // Parent file
71 const char *ParentFile() { return (const char *)(srcfile.c_str()); }
72
73 // Proxy type
74 const char *ProxyType() const { return cpxytype[pxytype]; }
75
76 // Key strength
77 int BitStrength() { return ((cert) ? EVP_PKEY_bits(X509_get_pubkey(cert)) : -1);}
78
79 // Serial number
82
83 // Validity
84 time_t NotBefore(); // get begin-validity time in secs since Epoch
85 time_t NotAfter(); // get end-validity time in secs since Epoch
86
87 // Relevant Names
88 const char *Subject(); // get subject name
89 const char *Issuer(); // get issuer name
90
91 // Relevant hashes
92 const char *SubjectHash(int = 0); // get hash of subject name
93 const char *IssuerHash(int = 0); // get hash of issuer name
94
95 // Check SANs
96 virtual bool MatchesSAN(const char *, bool &);
97
98 // Retrieve a given extension if there (in opaque form)
99 XrdCryptoX509data GetExtension(const char *oid);
100
101 // Verify signature
102 bool Verify(XrdCryptoX509 *ref);
103
104private:
105 X509 *cert; // The certificate object
106 time_t notbefore; // begin-validity time in secs since Epoch
107 time_t notafter; // end-validity time in secs since Epoch
108 XrdOucString subject; // subject;
109 XrdOucString issuer; // issuer name;
110 XrdOucString subjecthash; // Default hash of subject;
111 XrdOucString issuerhash; // Default hash of issuer name;
112 XrdOucString subjectoldhash; // Old (md5) hash of subject if v >= 1.0.0;
113 XrdOucString issueroldhash; // Old (md5) hash of issuer name if v >= 1.0.0;
114 XrdOucString srcfile; // source file name, if any;
115 XrdSutBucket *bucket; // Bucket for export operations
116 XrdCryptoRSA *pki; // PKI of the certificate
117 int pxytype; // Type of proxy (RFC, gsi 3, legacy gsi 2)
118
119 int FillUnknownExt(const unsigned char **pp, long length, bool dump = 0);
120 int Asn1PrintInfo(int tag, int xclass, int constructed, int indent);
121 void CertType();
122
123 static const char *cpxytype[5]; // Names of types
124};
125
126#endif
long long kXR_int64
Definition XPtypes.hh:98
void * XrdCryptoX509data
bool DumpExtensions
const char * SubjectHash()
const char * IssuerHash()
const char * Issuer()
XrdCryptoX509data GetExtension(const char *oid)
const char * Subject()
XrdCryptoRSA * PKI()
XrdOucString SerialNumberString()
const char * ProxyType() const
XrdCryptoX509data Opaque()
bool Verify(XrdCryptoX509 *ref)
XrdSutBucket * Export()
virtual bool MatchesSAN(const char *, bool &)
XrdCryptosslX509(const char *cf, const char *kf=0)
const char * ParentFile()
void SetPKI(XrdCryptoX509data pki)