reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
resip::WinSecurity Class Reference

WARNING - This class is only appropriate for client TLS connections, as it only loads root certs. More...

#include <WinSecurity.hxx>

Inheritance diagram for resip::WinSecurity:
[legend]

Public Types

enum  MsCertStoreType { ROOT_CA_STORE =1 , CA_STORE =2 , PRIVATE_STORE =3 , USERS_STORE =4 }
 
- Public Types inherited from resip::BaseSecurity
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

 WinSecurity (const CipherList &cipherList=ExportableSuite, const Data &defaultPrivateKeyPassPhrase=Data::Empty, const Data &dHParamsFilename=Data::Empty)
 
 WinSecurity (const Data &pathToCerts, const CipherList &cipherList=ExportableSuite, const Data &defaultPrivateKeyPassPhrase=Data::Empty, const Data &dHParamsFilename=Data::Empty)
 
virtual void preload ()
 
virtual void onReadPEM (const Data &name, PEMType type, Data &buffer) const
 
virtual void onWritePEM (const Data &name, PEMType type, const Data &buffer) const
 
virtual void onRemovePEM (const Data &name, PEMType type) const
 
- Public Member Functions inherited from resip::Security
 Security (const Data &pathToCerts, const CipherList &=StrongestSuite, const Data &defaultPrivateKeyPassPhrase=Data::Empty, const Data &dHParamsFilename=Data::Empty)
 
 Security (const CipherList &=StrongestSuite, const Data &defaultPrivateKeyPassPhrase=Data::Empty, const Data &dHParamsFilename=Data::Empty)
 
void addCADirectory (const Data &caDirectory)
 
void addCAFile (const Data &caFile)
 
void loadCADirectory (const Data &directoryName)
 
void loadCAFile (const Data &fileName)
 
virtual SSL_CTX * createDomainCtx (const SSL_METHOD *method, const Data &domain, const Data &certificateFilename, const Data &privateKeyFilename, const Data &privateKeyPassPhrase)
 Throws BaseSecurity::Exception if the certificate or private key can't be loaded; nothing is left allocated in that case.
 
virtual void updateDomainCtx (SSL_CTX *ctx, const Data &domain, const Data &certificateFilename, const Data &privateKeyFilename, const Data &privateKeyPassPhrase)
 Loads the domain's certificate chain and private key into ctx.
 
- Public Member Functions inherited from resip::BaseSecurity
 BaseSecurity (const CipherList &cipherSuite=StrongestSuite, const Data &defaultPrivateKeyPassPhrase=Data::Empty, const Data &dHParamsFilename=Data::Empty)
 
virtual ~BaseSecurity ()
 
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)
 

Protected Member Functions

HCERTSTORE openSystemCertStore (const Data &name)
 
void getCerts (MsCertStoreType eType)
 
void getCredentials (MsCertStoreType eType)
 
void closeCertifStore (HCERTSTORE)
 
- Protected Member Functions inherited from resip::BaseSecurity
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)
 

Additional Inherited Members

- Static Public Member Functions inherited from resip::BaseSecurity
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 inherited from resip::BaseSecurity
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
 
- Static Protected Member Functions inherited from resip::BaseSecurity
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 inherited from resip::BaseSecurity
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 inherited from resip::BaseSecurity
static bool mAllowWildcardCertificates = false
 

Detailed Description

WARNING - This class is only appropriate for client TLS connections, as it only loads root certs.

There is currently no logic to load domain or user certificates.

Definition at line 21 of file WinSecurity.hxx.

Member Enumeration Documentation

◆ MsCertStoreType

Enumerator
ROOT_CA_STORE 
CA_STORE 
PRIVATE_STORE 
USERS_STORE 

Definition at line 25 of file WinSecurity.hxx.

Constructor & Destructor Documentation

◆ WinSecurity() [1/2]

resip::WinSecurity::WinSecurity ( const CipherList &  cipherList = ExportableSuite,
const Data &  defaultPrivateKeyPassPhrase = Data::Empty,
const Data &  dHParamsFilename = Data::Empty 
)
inline

Definition at line 39 of file WinSecurity.hxx.

◆ WinSecurity() [2/2]

resip::WinSecurity::WinSecurity ( const Data &  pathToCerts,
const CipherList &  cipherList = ExportableSuite,
const Data &  defaultPrivateKeyPassPhrase = Data::Empty,
const Data &  dHParamsFilename = Data::Empty 
)
inline

Definition at line 43 of file WinSecurity.hxx.

Member Function Documentation

◆ closeCertifStore()

void WinSecurity::closeCertifStore ( HCERTSTORE  storeHandle)
protected

Definition at line 159 of file WinSecurity.cxx.

◆ getCerts()

void WinSecurity::getCerts ( MsCertStoreType  eType)
protected

Definition at line 168 of file WinSecurity.cxx.

◆ getCredentials()

void WinSecurity::getCredentials ( MsCertStoreType  eType)
protected

Definition at line 210 of file WinSecurity.cxx.

◆ onReadPEM()

void WinSecurity::onReadPEM ( const Data &  name,
PEMType  type,
Data &  buffer 
) const
virtual

Reimplemented from resip::Security.

Definition at line 46 of file WinSecurity.cxx.

◆ onRemovePEM()

void WinSecurity::onRemovePEM ( const Data &  name,
PEMType  type 
) const
virtual

Reimplemented from resip::Security.

Definition at line 58 of file WinSecurity.cxx.

◆ onWritePEM()

void WinSecurity::onWritePEM ( const Data &  name,
PEMType  type,
const Data &  buffer 
) const
virtual

Reimplemented from resip::Security.

Definition at line 52 of file WinSecurity.cxx.

◆ openSystemCertStore()

HCERTSTORE WinSecurity::openSystemCertStore ( const Data &  name)
protected

Definition at line 116 of file WinSecurity.cxx.

◆ preload()

void WinSecurity::preload ( )
virtual

Reimplemented from resip::Security.

Definition at line 34 of file WinSecurity.cxx.


The documentation for this class was generated from the following files: