|
xrootd
|
00001 #ifndef __CRYPTO_SSLX509_H__ 00002 #define __CRYPTO_SSLX509_H__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C r y p t o s s l X 5 0 9 . h h */ 00006 /* */ 00007 /* (c) 2005 G. Ganis , CERN */ 00008 /* */ 00009 /* This file is part of the XRootD software suite. */ 00010 /* */ 00011 /* XRootD is free software: you can redistribute it and/or modify it under */ 00012 /* the terms of the GNU Lesser General Public License as published by the */ 00013 /* Free Software Foundation, either version 3 of the License, or (at your */ 00014 /* option) any later version. */ 00015 /* */ 00016 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00017 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00018 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00019 /* License for more details. */ 00020 /* */ 00021 /* You should have received a copy of the GNU Lesser General Public License */ 00022 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00023 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00024 /* */ 00025 /* The copyright holder's institutional names and contributor's names may not */ 00026 /* be used to endorse or promote products derived from this software without */ 00027 /* specific prior written permission of the institution or contributor. */ 00028 /* */ 00029 /******************************************************************************/ 00030 00031 /* ************************************************************************** */ 00032 /* */ 00033 /* OpenSSL implementation of XrdCryptoX509 */ 00034 /* */ 00035 /* ************************************************************************** */ 00036 00037 #include "XrdCrypto/XrdCryptoX509.hh" 00038 00039 #include <openssl/x509v3.h> 00040 #include <openssl/bio.h> 00041 #include <openssl/evp.h> 00042 00043 // ---------------------------------------------------------------------------// 00044 // 00045 // OpenSSL X509 implementation 00046 // 00047 // ---------------------------------------------------------------------------// 00048 class XrdCryptosslX509 : public XrdCryptoX509 00049 { 00050 00051 public: 00052 XrdCryptosslX509(const char *cf, const char *kf = 0); 00053 XrdCryptosslX509(XrdSutBucket *bck); 00054 XrdCryptosslX509(X509 *cert); 00055 virtual ~XrdCryptosslX509(); 00056 00057 // Access underlying data (in opaque form: used in chains) 00058 XrdCryptoX509data Opaque() { return (XrdCryptoX509data)cert; } 00059 00060 // Access certificate key 00061 XrdCryptoRSA *PKI() { return pki; } 00062 void SetPKI(XrdCryptoX509data pki); 00063 00064 // Export in form of bucket (for transfers) 00065 XrdSutBucket *Export(); 00066 00067 // Parent file 00068 const char *ParentFile() { return (const char *)(srcfile.c_str()); } 00069 00070 // Key strength 00071 int BitStrength() { return ((cert) ? EVP_PKEY_bits(X509_get_pubkey(cert)) : -1);} 00072 00073 // Serial number 00074 kXR_int64 SerialNumber(); 00075 XrdOucString SerialNumberString(); 00076 00077 // Validity 00078 int NotBefore(); // get begin-validity time in secs since Epoch 00079 int NotAfter(); // get end-validity time in secs since Epoch 00080 00081 // Relevant Names 00082 const char *Subject(); // get subject name 00083 const char *Issuer(); // get issuer name 00084 00085 // Relevant hashes 00086 const char *SubjectHash(int = 0); // get hash of subject name 00087 const char *IssuerHash(int = 0); // get hash of issuer name 00088 00089 // Retrieve a given extension if there (in opaque form) 00090 XrdCryptoX509data GetExtension(const char *oid); 00091 00092 // Verify signature 00093 bool Verify(XrdCryptoX509 *ref); 00094 00095 private: 00096 X509 *cert; // The certificate object 00097 int notbefore; // begin-validity time in secs since Epoch 00098 int notafter; // end-validity time in secs since Epoch 00099 XrdOucString subject; // subject; 00100 XrdOucString issuer; // issuer name; 00101 XrdOucString subjecthash; // Default hash of subject; 00102 XrdOucString issuerhash; // Default hash of issuer name; 00103 XrdOucString subjectoldhash; // Old (md5) hash of subject if v >= 1.0.0; 00104 XrdOucString issueroldhash; // Old (md5) hash of issuer name if v >= 1.0.0; 00105 XrdOucString srcfile; // source file name, if any; 00106 XrdSutBucket *bucket; // Bucket for export operations 00107 XrdCryptoRSA *pki; // PKI of the certificate 00108 00109 bool IsCA(); // Find out if we are a CA 00110 00111 }; 00112 00113 #endif
1.7.6.1