Chapter 6 Using SSL in C++ Clients


Retrieving session security information

To retrieve security information about the session, narrow the component object reference, typeObj, to an SSL session, sslSession. Then use the getSessionInfo method to retrieve the session information from the SSL session and create an object reference for the session information. Use individual get methods to retrieve information about each SSL session property.

Note   You cannot use the getName, getPassword, getAuthenticationStatus, getListener, getPeerAddress, getHostName. These methods are inherited from the SessionInfo interface.

// Obtain SSLSession information from 
// typesObj. CtsSecurity::SSLSession_var sslSession =     CtsSecurity::SSLSession::
    _narrow(typesObj); CtsSecurity::SSLSessionInfo_var 
    sslSessionInfo = sslSession->getSessionInfo();

// Obtain user data (similar usage in user's 
// SSL callback implementation) String_var currentUserData = 
    sslSessionInfo->getProperty("userData");

// Obtain details about server's certificate. CtsSecurity::X509Certificate_var serverX509=    sslSessionInfo->getPeerCertificate(); cout << "Connected to server: << 
    serverX509->getSubjectDN() << endl"; // get details about my certificate CtsSecurity::X509Certificate_var clientX509= 
    sslSessionInfo->getCertificate(); 

 


Copyright © 2002 Sybase, Inc. All rights reserved.