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 TypeFunction nameArguments
int32_tSNI_Callback(SSL*,int*,void*,)

Declared and defined in file: hzIpServer.cpp

Function Logic:

0:START 1:type svrName 2:unknown 3:items 4:Return SSL_TLSEXT_ERR_OK 5:items pSSL_Regime 6:unknown 7:items 8:Return SSL_TLSEXT_ERR_OK 9:unknown 10:items 11:Return SSL_TLSEXT_ERR_OK 12:items items items 13:Return SSL_TLSEXT_ERR_OK

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 ;
}