|
reSIProcate
SIP stack, Dialog Usage Manager and related libraries
|
#include <Security.hxx>
Classes | |
| struct | CertificateInfo |
| class | CipherList |
| class | Exception |
| struct | PeerName |
Public Types | |
| enum | NameType { SubjectAltName , CommonName } |
| enum | PEMType { RootCert =1 , DomainCert , DomainPrivateKey , UserCert , UserPrivateKey } |
| typedef std::vector< CertificateInfo > | CertificateInfoContainer |
| typedef std::map< Data, X509 * > | X509Map |
| typedef std::list< X509 * > | X509List |
| typedef std::map< Data, EVP_PKEY * > | PrivateKeyMap |
| typedef std::map< Data, Data > | PassPhraseMap |
Public Member Functions | |
| BaseSecurity (const CipherList &cipherSuite=StrongestSuite, const Data &defaultPrivateKeyPassPhrase=Data::Empty, const Data &dHParamsFilename=Data::Empty) | |
| virtual | ~BaseSecurity () |
| virtual void | preload ()=0 |
| virtual void | onReadPEM (const Data &name, PEMType type, Data &buffer) const =0 |
| virtual void | onWritePEM (const Data &name, PEMType type, const Data &buffer) const =0 |
| virtual void | onRemovePEM (const Data &name, PEMType type) const =0 |
| CertificateInfoContainer | getRootCertDescriptions () const |
| void | addRootCertPEM (const Data &x509PEMEncodedRootCerts) |
| void | addDomainCertPEM (const Data &domainName, const Data &certPEM) |
| void | addDomainCertDER (const Data &domainName, const Data &certDER) |
| bool | hasDomainCert (const Data &domainName, bool logErrors=true) const |
| void | removeDomainCert (const Data &domainName) |
| Data | getDomainCertDER (const Data &domainName) const |
| void | addDomainPrivateKeyPEM (const Data &domainName, const Data &privateKeyPEM, const Data &privateKeyPassPhrase=Data::Empty) |
| bool | hasDomainPrivateKey (const Data &domainName) const |
| void | removeDomainPrivateKey (const Data &domainName) |
| Data | getDomainPrivateKeyPEM (const Data &domainName) const |
| void | addUserCertPEM (const Data &aor, const Data &certPEM) |
| void | addUserCertDER (const Data &aor, const Data &certDER) |
| bool | hasUserCert (const Data &aor) const |
| void | removeUserCert (const Data &aor) |
| Data | getUserCertDER (const Data &aor) const |
| void | setUserPassPhrase (const Data &aor, const Data &passPhrase) |
| bool | hasUserPassPhrase (const Data &aor) const |
| void | removeUserPassPhrase (const Data &aor) |
| Data | getUserPassPhrase (const Data &aor) const |
| void | addUserPrivateKeyPEM (const Data &aor, const Data &certPEM, const Data &privateKeyPassPhrase=Data::Empty) |
| void | addUserPrivateKeyDER (const Data &aor, const Data &certDER, const Data &privateKeyPassPhrase=Data::Empty) |
| bool | hasUserPrivateKey (const Data &aor) const |
| void | removeUserPrivateKey (const Data &aor) |
| Data | getUserPrivateKeyPEM (const Data &aor) const |
| Data | getUserPrivateKeyDER (const Data &aor) const |
| void | generateUserCert (const Data &aor, int expireDays=365, int keyLen=2048) |
| MultipartSignedContents * | sign (const Data &senderAor, Contents *) |
| Pkcs7Contents * | encrypt (Contents *, const Data &recipCertName) |
| MultipartSignedContents * | signAndEncrypt (const Data &senderAor, Contents *, const Data &recipCertName) |
| Data | computeIdentity (const Data &signerDomain, const Data &in) const |
| bool | checkIdentity (const Data &signerDomain, const Data &in, const Data &sig, X509 *cert=NULL) const |
| void | checkAndSetIdentity (SipMessage &msg, const Data &derCert=Data::Empty) const |
| Contents * | decrypt (const Data &decryptorAor, const Pkcs7Contents *) |
| Contents * | checkSignature (MultipartSignedContents *, Data *signedBy, SignatureStatus *sigStat) |
| SSL_CTX * | getTlsCtx () |
| SSL_CTX * | getSslCtx () |
| X509 * | getDomainCert (const Data &domain) |
| EVP_PKEY * | getDomainKey (const Data &domain) |
| X509 * | getUserCert (const Data &aor) |
| EVP_PKEY * | getUserPrivateKey (const Data &aor) |
Static Public Member Functions | |
| static int | getResipConnectionExDataIdx () |
| static void | initialize () |
| static Data | getCertName (X509 *cert) |
| static void | getCertNames (X509 *cert, std::list< PeerName > &peerNames, bool useEmailAsSIP=false) |
| static bool | isSelfSigned (const X509 *cert) |
| static int | matchHostName (const Data &certificateName, const Data &domainName) |
| Applies the certificate and domain name matching rules. | |
| static void | setAllowWildcardCertificates (bool bEnable) |
| static bool | allowWildcardCertificates () |
| static SecurityTypes::SSLType | parseSSLType (const Data &typeName) |
| Converts a string containing an SSL type name to the corresponding enum value. | |
| static long | parseOpenSSLCTXOption (const Data &optionName) |
| Converts a string containing an OpenSSL option name (for SSL_CTX_set_options) to the numeric value from ssl.h - see resip::parseOpenSSLCTXOption. | |
Static Public Attributes | |
| static CipherList | ExportableSuite |
| static CipherList | StrongestSuite |
| static long | OpenSSLCTXSetOptions = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION |
| Note: | |
| static long | OpenSSLCTXClearOptions = 0 |
Protected Member Functions | |
| void | addCertPEM (PEMType type, const Data &name, const Data &certPEM, bool write) |
| void | addCertDER (PEMType type, const Data &name, const Data &certDER, bool write) |
| bool | hasCert (PEMType type, const Data &name, bool logErrors=true) const |
| void | removeCert (PEMType type, const Data &name) |
| Data | getCertDER (PEMType type, const Data &name) const |
| void | addCertX509 (PEMType type, const Data &name, X509 *cert, bool write) |
| void | addPrivateKeyPEM (PEMType type, const Data &name, const Data &privateKeyPEM, bool write, const Data &privateKeyPassPhrase=Data::Empty) |
| void | addPrivateKeyDER (PEMType type, const Data &name, const Data &privateKeyDER, bool write, const Data &privateKeyPassPhrase=Data::Empty) |
| bool | hasPrivateKey (PEMType type, const Data &name) const |
| void | removePrivateKey (PEMType type, const Data &name) |
| Data | getPrivateKeyPEM (PEMType type, const Data &name) const |
| Data | getPrivateKeyDER (PEMType type, const Data &name) const |
| void | addPrivateKeyPKEY (PEMType type, const Data &name, EVP_PKEY *pKey, bool write) |
| void | setDHParams (SSL_CTX *ctx) |
Static Protected Member Functions | |
| static void | dumpAsn (const char *, Data) |
| static int | matchHostNameWithWildcards (const Data &certificateName, const Data &domainName) |
| Matches a certificate name, which may hold a wildcard, against the domain name we connected to, following RFC 6125 section 6.4.3: the wildcard has to be the whole left-most label ("*.example.com"), it stands for exactly one non-empty label of the domain name, at least two labels have to follow it, and it never matches an IP address. | |
Protected Attributes | |
| SSL_CTX * | mTlsCtx |
| Note: | |
| SSL_CTX * | mSslCtx |
| CipherList | mCipherList |
| Data | mDefaultPrivateKeyPassPhrase |
| Data | mDHParamsFilename |
| X509List | mRootCerts |
| X509_STORE * | mRootTlsCerts |
| X509_STORE * | mRootSslCerts |
| X509Map | mDomainCerts |
| PrivateKeyMap | mDomainPrivateKeys |
| X509Map | mUserCerts |
| PassPhraseMap | mUserPassPhrases |
| PrivateKeyMap | mUserPrivateKeys |
Static Protected Attributes | |
| static bool | mAllowWildcardCertificates = false |
Definition at line 43 of file Security.hxx.
| typedef std::vector<CertificateInfo> resip::BaseSecurity::CertificateInfoContainer |
Definition at line 127 of file Security.hxx.
| typedef std::map<Data,Data> resip::BaseSecurity::PassPhraseMap |
Definition at line 216 of file Security.hxx.
| typedef std::map<Data,EVP_PKEY*> resip::BaseSecurity::PrivateKeyMap |
Definition at line 215 of file Security.hxx.
| typedef std::list<X509*> resip::BaseSecurity::X509List |
Definition at line 214 of file Security.hxx.
| typedef std::map<Data,X509*> resip::BaseSecurity::X509Map |
Definition at line 213 of file Security.hxx.
| Enumerator | |
|---|---|
| SubjectAltName | |
| CommonName | |
Definition at line 67 of file Security.hxx.
| Enumerator | |
|---|---|
| RootCert | |
| DomainCert | |
| DomainPrivateKey | |
| UserCert | |
| UserPrivateKey | |
Definition at line 102 of file Security.hxx.
| BaseSecurity::BaseSecurity | ( | const CipherList & | cipherSuite = StrongestSuite, |
| const Data & | defaultPrivateKeyPassPhrase = Data::Empty, |
||
| const Data & | dHParamsFilename = Data::Empty |
||
| ) |
Definition at line 1174 of file Security.cxx.
|
virtual |
Definition at line 1249 of file Security.cxx.
|
protected |
Definition at line 550 of file Security.cxx.
|
protected |
Definition at line 574 of file Security.cxx.
|
protected |
Definition at line 613 of file Security.cxx.
Definition at line 1337 of file Security.cxx.
Definition at line 1331 of file Security.cxx.
| void BaseSecurity::addDomainPrivateKeyPEM | ( | const Data & | domainName, |
| const Data & | privateKeyPEM, | ||
| const Data & | privateKeyPassPhrase = Data::Empty |
||
| ) |
Definition at line 1361 of file Security.cxx.
|
protected |
Definition at line 874 of file Security.cxx.
|
protected |
Definition at line 940 of file Security.cxx.
|
protected |
Definition at line 791 of file Security.cxx.
| void BaseSecurity::addRootCertPEM | ( | const Data & | x509PEMEncodedRootCerts | ) |
Definition at line 1290 of file Security.cxx.
Definition at line 1391 of file Security.cxx.
Definition at line 1385 of file Security.cxx.
| void BaseSecurity::addUserPrivateKeyDER | ( | const Data & | aor, |
| const Data & | certDER, | ||
| const Data & | privateKeyPassPhrase = Data::Empty |
||
| ) |
Definition at line 1477 of file Security.cxx.
| void BaseSecurity::addUserPrivateKeyPEM | ( | const Data & | aor, |
| const Data & | certPEM, | ||
| const Data & | privateKeyPassPhrase = Data::Empty |
||
| ) |
Definition at line 1471 of file Security.cxx.
|
inlinestatic |
Definition at line 198 of file Security.hxx.
| void BaseSecurity::checkAndSetIdentity | ( | SipMessage & | msg, |
| const Data & | derCert = Data::Empty |
||
| ) | const |
Definition at line 1965 of file Security.cxx.
| bool BaseSecurity::checkIdentity | ( | const Data & | signerDomain, |
| const Data & | in, | ||
| const Data & | sig, | ||
| X509 * | cert = NULL |
||
| ) | const |
Definition at line 1899 of file Security.cxx.
| Contents * BaseSecurity::checkSignature | ( | MultipartSignedContents * | multi, |
| Data * | signedBy, | ||
| SignatureStatus * | sigStat | ||
| ) |
Definition at line 2233 of file Security.cxx.
Definition at line 1831 of file Security.cxx.
| Contents * BaseSecurity::decrypt | ( | const Data & | decryptorAor, |
| const Pkcs7Contents * | contents | ||
| ) |
Definition at line 2015 of file Security.cxx.
|
staticprotected |
Definition at line 2903 of file Security.cxx.
| Pkcs7Contents * BaseSecurity::encrypt | ( | Contents * | bodyIn, |
| const Data & | recipCertName | ||
| ) |
Definition at line 1724 of file Security.cxx.
| void BaseSecurity::generateUserCert | ( | const Data & | aor, |
| int | expireDays = 365, |
||
| int | keyLen = 2048 |
||
| ) |
Definition at line 1507 of file Security.cxx.
Definition at line 752 of file Security.cxx.
Definition at line 2785 of file Security.cxx.
|
static |
Definition at line 2593 of file Security.cxx.
Definition at line 2925 of file Security.cxx.
Definition at line 1355 of file Security.cxx.
Definition at line 2947 of file Security.cxx.
Definition at line 1379 of file Security.cxx.
Definition at line 1102 of file Security.cxx.
Definition at line 1052 of file Security.cxx.
|
static |
Definition at line 101 of file Security.cxx.
| Security::CertificateInfoContainer BaseSecurity::getRootCertDescriptions | ( | ) | const |
Definition at line 1281 of file Security.cxx.
| SSL_CTX * BaseSecurity::getSslCtx | ( | ) |
Definition at line 2586 of file Security.cxx.
| SSL_CTX * BaseSecurity::getTlsCtx | ( | ) |
Definition at line 2578 of file Security.cxx.
Definition at line 2936 of file Security.cxx.
Definition at line 1409 of file Security.cxx.
Definition at line 1455 of file Security.cxx.
Definition at line 2958 of file Security.cxx.
Definition at line 1501 of file Security.cxx.
Definition at line 1495 of file Security.cxx.
|
protected |
Definition at line 690 of file Security.cxx.
| bool BaseSecurity::hasDomainCert | ( | const Data & | domainName, |
| bool | logErrors = true |
||
| ) | const |
Definition at line 1343 of file Security.cxx.
| bool BaseSecurity::hasDomainPrivateKey | ( | const Data & | domainName | ) | const |
Definition at line 1367 of file Security.cxx.
Definition at line 1016 of file Security.cxx.
| bool BaseSecurity::hasUserCert | ( | const Data & | aor | ) | const |
Definition at line 1397 of file Security.cxx.
| bool BaseSecurity::hasUserPassPhrase | ( | const Data & | aor | ) | const |
Definition at line 1427 of file Security.cxx.
| bool BaseSecurity::hasUserPrivateKey | ( | const Data & | aor | ) | const |
Definition at line 1483 of file Security.cxx.
|
static |
Definition at line 1275 of file Security.cxx.
|
static |
Definition at line 2895 of file Security.cxx.
Applies the certificate and domain name matching rules.
Definition at line 2817 of file Security.cxx.
|
staticprotected |
Matches a certificate name, which may hold a wildcard, against the domain name we connected to, following RFC 6125 section 6.4.3: the wildcard has to be the whole left-most label ("*.example.com"), it stands for exactly one non-empty label of the domain name, at least two labels have to follow it, and it never matches an IP address.
Definition at line 2863 of file Security.cxx.
|
pure virtual |
Implemented in resip::MacSecurity, resip::Security, and resip::WinSecurity.
|
pure virtual |
Implemented in resip::MacSecurity, resip::Security, and resip::WinSecurity.
|
pure virtual |
Implemented in resip::MacSecurity, resip::Security, and resip::WinSecurity.
|
static |
Converts a string containing an OpenSSL option name (for SSL_CTX_set_options) to the numeric value from ssl.h - see resip::parseOpenSSLCTXOption.
Definition at line 2851 of file Security.cxx.
|
static |
Converts a string containing an SSL type name to the corresponding enum value.
Definition at line 2833 of file Security.cxx.
|
pure virtual |
Implemented in resip::MacSecurity, resip::Security, and resip::WinSecurity.
Definition at line 734 of file Security.cxx.
| void BaseSecurity::removeDomainCert | ( | const Data & | domainName | ) |
Definition at line 1349 of file Security.cxx.
| void BaseSecurity::removeDomainPrivateKey | ( | const Data & | domainName | ) |
Definition at line 1373 of file Security.cxx.
Definition at line 1151 of file Security.cxx.
| void BaseSecurity::removeUserCert | ( | const Data & | aor | ) |
Definition at line 1403 of file Security.cxx.
| void BaseSecurity::removeUserPassPhrase | ( | const Data & | aor | ) |
Definition at line 1443 of file Security.cxx.
| void BaseSecurity::removeUserPrivateKey | ( | const Data & | aor | ) |
Definition at line 1489 of file Security.cxx.
|
inlinestatic |
Definition at line 197 of file Security.hxx.
|
protected |
Definition at line 2969 of file Security.cxx.
Definition at line 1415 of file Security.cxx.
| MultipartSignedContents * BaseSecurity::sign | ( | const Data & | senderAor, |
| Contents * | contents | ||
| ) |
Definition at line 1606 of file Security.cxx.
| MultipartSignedContents * BaseSecurity::signAndEncrypt | ( | const Data & | senderAor, |
| Contents * | body, | ||
| const Data & | recipCertName | ||
| ) |
Definition at line 1822 of file Security.cxx.
|
static |
Definition at line 80 of file Security.hxx.
|
staticprotected |
Definition at line 266 of file Security.hxx.
|
protected |
Definition at line 233 of file Security.hxx.
|
protected |
Definition at line 234 of file Security.hxx.
|
protected |
Definition at line 235 of file Security.hxx.
|
protected |
Definition at line 242 of file Security.hxx.
|
protected |
Definition at line 243 of file Security.hxx.
|
protected |
Definition at line 238 of file Security.hxx.
|
protected |
Definition at line 240 of file Security.hxx.
|
protected |
Definition at line 239 of file Security.hxx.
|
protected |
Definition at line 230 of file Security.hxx.
|
protected |
Note:
mTlsCtx is being used when TLSv1 is requested. Adding more non-static fields like mTlsCtx for subsequent versions (e.g. for OpenSSL TLSv1_1_method()) breaks ABI compatability and is therefore difficult to backport onto release branches. Better to use DynamicTLS and use OpenSSL options flags to specify the exact protocol versions to support.
Definition at line 229 of file Security.hxx.
|
protected |
Definition at line 245 of file Security.hxx.
|
protected |
Definition at line 246 of file Security.hxx.
|
protected |
Definition at line 247 of file Security.hxx.
|
static |
Definition at line 92 of file Security.hxx.
|
static |
Note:
To allow these to be backported to v1.9.x without ABI breakage, they are implemented as static fields. In the next release branch, non-static versions could be added and the static values used as defaults.
When DynamicTLS/SSLv23 mode is selected OpenSSL will allow a dynamic choice of SSL/TLS versions on each connection. Set flags like SSL_OP_NO_SSLv2 and SSL_OP_NO_SSLv3 in order to disable older protocols.
An application must change these flags before creating the SSL_CTX object / Security object instance.
Definition at line 91 of file Security.hxx.
|
static |
Definition at line 81 of file Security.hxx.