00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00029
00030
00031
00032 #ifndef Pegasus_SSLContext_h
00033 #define Pegasus_SSLContext_h
00034
00035 #include <Pegasus/Common/CIMDateTime.h>
00036 #include <Pegasus/Common/Config.h>
00037 #include <Pegasus/Common/String.h>
00038 #include <Pegasus/Common/Exception.h>
00039 #include <Pegasus/Common/Linkage.h>
00040
00041 #ifdef PEGASUS_HAS_SSL
00042 typedef struct x509_store_st X509_STORE;
00043 #else
00044 # define X509_STORE int
00045 #endif
00046
00047 PEGASUS_NAMESPACE_BEGIN
00048
00049 class SSLCertificateInfoRep;
00050 class SSLContextRep;
00051 class SSLContext;
00052 class SSLSocket;
00053 class CIMServer;
00054 class SSLCertificateInfo;
00055 class SSLCallback;
00056 class SSLContextManager;
00057 class SSLCallbackInfoRep;
00058
00059
00060 typedef Boolean (SSLCertificateVerifyFunction) (SSLCertificateInfo &certInfo);
00061
00074 class PEGASUS_COMMON_LINKAGE SSLCallbackInfo
00075 {
00076 public:
00077
00081 static const int SSL_CALLBACK_INDEX;
00082
00089 SSLCallbackInfo(SSLCertificateVerifyFunction* verifyCert);
00090
00099 SSLCallbackInfo(
00100 SSLCertificateVerifyFunction* verifyCert,
00101 X509_STORE* crlStore);
00102
00106 ~SSLCallbackInfo();
00107
00108 private:
00109
00110 SSLCallbackInfo(
00111 SSLCertificateVerifyFunction* verifyCert,
00112 X509_STORE* crlStore,
00113 String ipAddress);
00114
00115 SSLCallbackInfo();
00116
00117 SSLCallbackInfo(const SSLCallbackInfo& sslCallbackInfo);
00118 SSLCallbackInfo& operator=(const SSLCallbackInfo& sslCallbackInfo);
00119
00120 SSLCallbackInfoRep* _rep;
00121
00122 friend class SSLSocket;
00123
00124 friend class SSLCallback;
00125 };
00126
00127
00131 class PEGASUS_COMMON_LINKAGE SSLCertificateInfo
00132 {
00133 public:
00134
00139 static const int V_OK;
00140
00142 static const int V_ERR_UNABLE_TO_GET_ISSUER_CERT;
00144 static const int V_ERR_UNABLE_TO_GET_CRL;
00146 static const int V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE;
00148 static const int V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE;
00150 static const int V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY;
00152 static const int V_ERR_CERT_SIGNATURE_FAILURE;
00154 static const int V_ERR_CRL_SIGNATURE_FAILURE;
00156 static const int V_ERR_CERT_NOT_YET_VALID;
00158 static const int V_ERR_CERT_HAS_EXPIRED;
00160 static const int V_ERR_CRL_NOT_YET_VALID;
00162 static const int V_ERR_CRL_HAS_EXPIRED;
00164 static const int V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD;
00166 static const int V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD;
00168 static const int V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD;
00170 static const int V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD;
00172 static const int V_ERR_OUT_OF_MEM;
00174 static const int V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT;
00176 static const int V_ERR_SELF_SIGNED_CERT_IN_CHAIN;
00178 static const int V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY;
00180 static const int V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE;
00182 static const int V_ERR_CERT_CHAIN_TOO_LONG;
00184 static const int V_ERR_CERT_REVOKED;
00186 static const int V_ERR_INVALID_CA;
00188 static const int V_ERR_PATH_LENGTH_EXCEEDED;
00190 static const int V_ERR_INVALID_PURPOSE;
00192 static const int V_ERR_CERT_UNTRUSTED;
00194 static const int V_ERR_CERT_REJECTED;
00196 static const int V_ERR_SUBJECT_ISSUER_MISMATCH;
00198 static const int V_ERR_AKID_SKID_MISMATCH;
00200 static const int V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
00202 static const int V_ERR_KEYUSAGE_NO_CERTSIGN;
00203
00205 static const int V_ERR_APPLICATION_VERIFICATION;
00206
00219 SSLCertificateInfo(
00220 const String subjectName,
00221 const String issuerName,
00222 const int errorDepth,
00223 const int errorCode,
00224 const int respCode);
00225
00229 SSLCertificateInfo(const SSLCertificateInfo& certificateInfo);
00230
00231 ~SSLCertificateInfo();
00232
00236 String getSubjectName() const;
00237
00241 String getIssuerName() const;
00242
00247 CIMDateTime getNotAfter() const;
00248
00253 CIMDateTime getNotBefore() const;
00254
00258 Uint32 getVersionNumber() const;
00259
00263 long getSerialNumber() const;
00264
00268 Uint32 getErrorDepth() const;
00269
00273 Uint32 getErrorCode() const;
00274
00278 void setErrorCode(const int errorCode);
00279
00283 String getErrorString() const;
00284
00288 Uint32 getResponseCode() const;
00289
00295 void setResponseCode(const int respCode);
00296
00300 String toString() const;
00301
00305 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
00306 const String &getPeerCertificate() const;
00307 #endif
00308
00309 private:
00310
00328 SSLCertificateInfo(
00329 const String subjectName,
00330 const String issuerName,
00331 const Uint32 versionNumber,
00332 const long serialNumber,
00333 const CIMDateTime notBefore,
00334 const CIMDateTime notAfter,
00335 const Uint32 depth,
00336 const Uint32 errorCode,
00337 const String errorString,
00338 const Uint32 respCode);
00339
00340 SSLCertificateInfo();
00341 SSLCertificateInfo& operator=(const SSLCertificateInfo& sslCertificateInfo);
00342
00343 SSLCertificateInfoRep* _rep;
00344
00345
00346
00347
00348 friend class SSLSocket;
00349
00350 friend class SSLCallback;
00351 };
00352
00356 class PEGASUS_COMMON_LINKAGE SSLContext
00357 {
00358 public:
00359
00381 SSLContext(
00382 const String& trustStore,
00383 SSLCertificateVerifyFunction* verifyCert,
00384 const String& randomFile = String::EMPTY);
00385
00390 SSLContext(const SSLContext& sslContext);
00391
00395 ~SSLContext();
00396
00401 String getTrustStore() const;
00402
00406 String getCertPath() const;
00407
00411 String getKeyPath() const;
00412
00416 String getCRLPath() const;
00417
00421 X509_STORE* getCRLStore() const;
00422
00423 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
00424
00427 String getCipherSuite() const;
00428 #endif
00429
00434 Boolean isPeerVerificationEnabled() const;
00435
00436 #ifdef PEGASUS_USE_DEPRECATED_INTERFACES
00437
00442 String getTrustStoreUserName() const;
00443 #endif
00444
00449 SSLCertificateVerifyFunction* getSSLCertificateVerifyFunction() const;
00450
00475 SSLContext(
00476 const String& trustStore,
00477 const String& certPath,
00478 const String& keyPath,
00479 SSLCertificateVerifyFunction* verifyCert,
00480 const String& randomFile);
00481
00482
00508 SSLContext(
00509 const String& trustStore,
00510 const String& certPath,
00511 const String& keyPath,
00512 const String& crlPath,
00513 SSLCertificateVerifyFunction* verifyCert,
00514 const String& randomFile);
00515
00516 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
00517
00543 SSLContext(
00544 const String& trustStore,
00545 const String& certPath,
00546 const String& keyPath,
00547 const String& crlPath,
00548 SSLCertificateVerifyFunction* verifyCert,
00549 const String& randomFile,
00550 const String& cipherSuite);
00551 #endif
00552
00553 #ifdef PEGASUS_USE_DEPRECATED_INTERFACES
00554
00571 SSLContext(
00572 const String& trustStore,
00573 const String& certPath,
00574 const String& keyPath,
00575 SSLCertificateVerifyFunction* verifyCert,
00576 String trustStoreUserName,
00577 const String& randomFile);
00578 #endif
00579
00580 private:
00581
00582 SSLContext();
00583 SSLContext& operator=(const SSLContext& sslContext);
00584
00585 void _validateCertificate();
00586
00587 SSLContextRep* _rep;
00588
00589 friend class SSLSocket;
00590 friend class CIMServer;
00591 friend class SSLContextManager;
00592 };
00593
00594 PEGASUS_NAMESPACE_END
00595
00596 #endif