Chapter 7 Using SSL in ActiveX Clients
When developing applications that interact with end users and support SSL, you should provide an SSL callback. The ORB invokes callback methods when required SSL settings have not been configured, or a setting has an incorrect value.
The callback can respond to exceptional conditions, such as server certificates that have expired. When using mutual authentication, the callback getCertificateLabel method allows you to present available certificates to the end user for them to choose. Lastly, the callback simplifies the handling of retry logic in the case where the user enters an invalid certificate password.
You can install a C++ callback or an ActiveX callback, but not both. C++ callbacks are discussed in "Creating CORBA C++ Clients" in the EAServer Programmer's Guide.
An ActiveX SSL callback must implement the methods in the CtsSecurity.SSLCallbackIntf interface. To install the callback, add a setting for the -ORBAXSSLCBComponent property in the ORB initialization string passed to the Orb.init method, as in the example below:
Dim orbOptions as String orbOptions = "-ORBAXSSLCBComponent=mySSLCBProj.mySSLCBComponent," orbOptions = orbOptions & "-ORBqop=sybpks_intl" Set orbRef = New JaguarTypeLibrary.ORB orbRef.Init (orbOptions)
The SSLCallbackIntf methods are as follows:
Public Function getCertificateLabel( _ ByVal sessionInfo As Object, _ ByVal labels As JaguarTypeLibrary.JCollection _ ) As String
Public Function getCredentialAttribute( _ ByVal sessionInfo As CtsSecurity.SSLSessionInfo, _ ByVal attr As Long, _ ByVal attrValues As JaguarTypeLibrary.JCollection _ ) As String
Attr value | To request |
---|---|
CtsSecurity. CRED_ATTR_ENTRUST_INIFILE (1) |
The full path and file name of the Entrust initialization file, which is usually %SYSTEMROOT%\entrust.ini. |
CtsSecurity. CRED_ATTR_ENTRUST_USERPROFILE (2) |
The full path and file name for the Entrust profile (.epf file). |
Public Function getPin( _ ByVal sessionInfo As Object, _ ByVal timedOut As Boolean _ ) As JaguarTypeLibrary.JCollection
Dim coll As JCollection Set coll = New JCollection Dim c As Byte Dim iter As Integer For iter = 1 To Len(pin) c = Asc(Mid(pin, iter, 1)) coll.Item(iter - 1) = c Next iter
Public Function trustVerify( _ ByVal sessionInfo As CtsSecurity.SSLSessionInfo, _ ByVal reason As Long _ ) As Long
Reason code | Description |
---|---|
CtsSecurity. REASON_CHAIN_INCOMPLETE (1) |
Server's certificate chain is incomplete. The ORB cannot complete the chain using the CA certificates in the Sybase certificate database. |
CtsSecurity. REASON_UNKNOWN_CA (2) |
The root CA in the server's certificate chain is not listed in the Sybase certificate database. |
CtsSecurity. REASON_CHAIN_EXPIRED (3) |
At least one certificate in the server's certificate chain has expired. |
CtsSecurity. REASON_TRUSTDBPINNOTSET (4) |
The password for the certificate database has not been set. Return CtsSecurity.TRUST_FAILED to cause the ORB to call the getPin callback method. |
CtsSecurity. REASON_TRUSTDBLOGINFAILED (5) |
The password for the certificate database was incorrect. Return CtsSecurity.TRUST_FAILED to cause the ORB to call the getPin callback method. |
Return code | Specified response |
---|---|
CtsSecurity.TRUST_ONCE (1) |
Accept the certificate, but only trust for one SSL connection. |
CtsSecurity.TRUST_FAIL (2) |
Fail the session, or if the reason is REASON_TRUSTDBPINNOTSET (4) or REASON_TRUSTDBLOGINFAILED (5), call the getPin method. |
CtsSecurity.TRUST_ALWAYS (3) |
Accept the certificate and add the server's CA to the list of trusted CAs in the Sybase certificate database. |
CtsSecurity.TRUST_NEVER (4) |
Reject the connection and mark the CA as not trusted in the Sybase certificate database. |
CtsSecurity.TRUST_SESSION (5) |
Trust the server certificate chain only during this client program's sessions. If the client program is restarted, the certificate chain is not trusted. |
CtsSecurity.TRUST_FAIL_SESSION (6) |
Reject the certificate now and any time it reappears during the life of this client program. Do not mark the certificate as untrusted in the Sybase certificate database. |
Your implementation of the getPin, getCertificateLabel, and getCredentialAttribute method should allow the user to cancel the connection attempt. In response to a user cancel, raise an ActiveX error exception to abort the SSL session. In Visual Basic, you can do this by raising an error with vbObjectError as the error number. If you provide an error description, and error logging has been enabled with the -ORBlogFile Orb property, the error description is written to the log. After an SSL session is cancelled, the client program receives a connection-fail error as it would from any other failed connection attempt.
For more information about these callback methods, see the documentation for the CtsSecurity::SSLCallback interface in the generated Interface Repository documentation.
Copyright © 2002 Sybase, Inc. All rights reserved. |