View Single Post
  #1 (permalink)  
Old 09-28-2005
kwaclaw kwaclaw is offline
Registered User
 
Name: Karl Waclawek
Organization: Toronto Star Newspapers Ltd.
Project: Proof of concept
 
Join Date: Sep 2004
Location: Oshawa, Canada
Posts: 143
Passing SSL connection details to application

I am currently finishing off an SSL plugin for IceCS (C#).
One of the things I would like to do is pass client certificate
information for a connection to the application, that is,
through Ice.Current.con().

Now, a generic way to do so would be to add an (opaque)
member to Connection, such as (in C# syntax):
Code:
    
    public interface _ConnectionOperationsNC
    {
        ...
        object info();  <-- new member
    }
This would also require to add the same kind of new member
to the Transceiver interface, and the method implemention
in the ConnectionI class would be:
Code:
        public object info()
        {
            return _transceiver.info();
        }
My Transceiver implementation (SslTransceiver in this case)
can then implement its info() method in any way it sees fit.

All the application needs to do is cast the object back
to a known type. Example (I modified the Hello server to
show the name on the client certificate):
Code:
    public override void sayHello(Ice.Current current)
    {
        string msg = string.Empty;
        SslStream ssl = current.con.info() as SslStream;
        if (ssl != null) {
            X509Certificate cert = ssl.RemoteCertificate;
            msg = cert.Subject + " says: ";
        }
        msg += "Hello World!";
        System.Console.Out.WriteLine(msg);
    }
Does that make sense to anyone?

Karl
__________________
Karl Waclawek
The Toronto Star - http://www.thestar.com
Reply With Quote