|
|
|||
File indexing completed on 2026-01-08 10:33:32
0001 #ifndef __CRYPTO_X509_H__ 0002 #define __CRYPTO_X509_H__ 0003 /******************************************************************************/ 0004 /* */ 0005 /* X r d C r y p t o X 5 0 9 . h h */ 0006 /* */ 0007 /* (c) 2005 G. Ganis , CERN */ 0008 /* */ 0009 /* This file is part of the XRootD software suite. */ 0010 /* */ 0011 /* XRootD is free software: you can redistribute it and/or modify it under */ 0012 /* the terms of the GNU Lesser General Public License as published by the */ 0013 /* Free Software Foundation, either version 3 of the License, or (at your */ 0014 /* option) any later version. */ 0015 /* */ 0016 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 0017 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 0018 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 0019 /* License for more details. */ 0020 /* */ 0021 /* You should have received a copy of the GNU Lesser General Public License */ 0022 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 0023 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 0024 /* */ 0025 /* The copyright holder's institutional names and contributor's names may not */ 0026 /* be used to endorse or promote products derived from this software without */ 0027 /* specific prior written permission of the institution or contributor. */ 0028 /* */ 0029 /******************************************************************************/ 0030 0031 /* ************************************************************************** */ 0032 /* */ 0033 /* Abstract interface for X509 certificates. */ 0034 /* Allows to plug-in modules based on different crypto implementation */ 0035 /* (OpenSSL, Botan, ...) */ 0036 /* */ 0037 /* ************************************************************************** */ 0038 0039 #include "XProtocol/XPtypes.hh" 0040 #include "XrdSut/XrdSutBucket.hh" 0041 #include "XrdCrypto/XrdCryptoRSA.hh" 0042 0043 typedef void * XrdCryptoX509data; 0044 0045 // ---------------------------------------------------------------------------// 0046 // 0047 // X509 interface 0048 // Describes one certificate 0049 // 0050 // ---------------------------------------------------------------------------// 0051 class XrdCryptoX509 { 0052 public: 0053 0054 // Certificate type 0055 enum EX509Type { kUnknown = -1, kCA = 0, kEEC = 1, kProxy = 2 }; 0056 EX509Type type; 0057 0058 0059 XrdCryptoX509() { type = kUnknown; } 0060 virtual ~XrdCryptoX509() { } 0061 0062 // Status 0063 virtual bool IsValid(int when = 0); // object correctly loaded 0064 virtual bool IsExpired(int when = 0); // Expired 0065 0066 // Access underlying data (in opaque form: used in chains) 0067 virtual XrdCryptoX509data Opaque(); 0068 0069 // Access certificate key 0070 virtual XrdCryptoRSA *PKI(); 0071 virtual void SetPKI(XrdCryptoX509data pki); 0072 0073 // Export in form of bucket (for transfers) 0074 virtual XrdSutBucket *Export(); 0075 0076 // Dump information 0077 virtual void Dump(); 0078 virtual int DumpExtensions(bool = 0); // extensions 0079 0080 const char *Type(EX509Type t = kUnknown) const 0081 { return ((t == kUnknown) ? ctype[type+1] : ctype[t+1]); } 0082 virtual const char *ParentFile(); 0083 virtual const char *ProxyType() const { return ""; } 0084 0085 // Key strength 0086 virtual int BitStrength(); 0087 0088 // Serial number 0089 virtual kXR_int64 SerialNumber(); 0090 virtual XrdOucString SerialNumberString(); 0091 0092 // Validity interval 0093 virtual time_t NotBefore(); // begin-validity time in secs since Epoch 0094 virtual time_t NotAfter(); // end-validity time in secs since Epoch 0095 0096 // Issuer of top certificate 0097 virtual const char *Issuer(); 0098 virtual const char *IssuerHash(int); // hash 0099 const char *IssuerHash() { return IssuerHash(0); } // hash 0100 0101 // Subject of bottom certificate 0102 virtual const char *Subject(); 0103 virtual const char *SubjectHash(int); // hash 0104 const char *SubjectHash() { return SubjectHash(0); } // hash 0105 0106 // Returns true if the certificate has a subject alt name which matches 0107 // the given hostnem. If it fals and hasSAN is false, there is no SAN extn. 0108 virtual bool MatchesSAN(const char * fqdn, bool &hasSAN) = 0; 0109 0110 // Retrieve a given extension if there (in opaque form) 0111 virtual XrdCryptoX509data GetExtension(const char *oid); 0112 0113 // Verify signature 0114 virtual bool Verify(XrdCryptoX509 *ref); 0115 0116 // Compare two hostnames, handling wildcards as appropriate. Necessary 0117 // for support for accepting connections where the remote X509 certificate 0118 // is a wildcard certificate. 0119 // 0120 // Returns true if the FQDN matches the specified pattern 0121 static bool MatchHostnames(const char *match_pattern, const char *fqdn); 0122 0123 private: 0124 0125 static const char *ctype[4]; // Names of types 0126 }; 0127 0128 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|