This is provided as a function pointer for use by SSL_accept() function, to establish which certificate to send to the clinet, on the basis of the domain name sought by the client.
| Return Type | Function name | Arguments |
|---|---|---|
| int32_t | SNI_Callback | (SSL*,int*,void*,) |
Declared and defined in file: hzIpServer.cpp
Function Logic:
Function body:
int32_t SNI_Callback (SSL* pSSL)int* al, void* arg,
{
// Category: Internet Server
//
// This is provided as a function pointer for use by SSL_accept() function, to establish which certificate to send to the clinet, on the basis of the domain name sought by the
// client.
_hzfunc("SNI_Callback") ;
_hz_SSL_Regime* pSSL_Regime ; // SSL Server context
hzString svrName ; // Server (domain) name requested by connecting client
int32_t type ; // Connection type?
type = SSL_get_servername_type(pSSL);
svrName = SSL_get_servername(pSSL, type) ;
if (!svrName)
{
threadLog("Server name req by client: NULL (type %d)\n", type) ;
return SSL_TLSEXT_ERR_OK ;
}
threadLog("Server name req by client: %s (type %d)\n", *svrName, type) ;
pSSL_Regime = s_mapSSLDoms[svrName] ;
if (!pSSL_Regime)
{
threadLog("Server name %s not found\n", *svrName) ;
return SSL_TLSEXT_ERR_OK ;
}
if (pSSL_Regime == s_SSL_svrRegime)
{
threadLog("Selecting default\n") ;
return SSL_TLSEXT_ERR_OK ;
}
// Swap the CTX
threadLog("Swaping CTX to %s\n", *pSSL_Regime->m_Domain) ;
SSL_set_tlsext_host_name(pSSL, *pSSL_Regime->m_Domain);
SSL_set_SSL_CTX(pSSL, pSSL_Regime->m_svrCTX);
return SSL_TLSEXT_ERR_OK ;
}