Hi Chris,

[email protected] wrote:
> I use Restlet Version 1.1
> 
> I tried it this way:
> 
> Client client = new Client(new Context(), Protocol.HTTPS);
>         Context con = client.getContext();
>         Series<Parameter> param1 = con.getParameters();
>         param1.add("sslContextFactory","MySSLContextFactory");
>         
> where MySSLContextFactory has the base class 
> com.noelios.restlet.util.SslContextFactory
> 
> But it is not working that way. 

Can you clarify how it's not working?


There's more documentation here:
[1] http://wiki.restlet.org/docs_1.1/13-restlet/27-restlet/46-restlet.html
[2] http://wiki.restlet.org/docs_1.1/13-restlet/28-restlet/153-restlet.html


There is a difference between using parameters and attributes when 
setting the context (as mentioned in [1]).
When passing the settings via parameters, "sslContextFactory" must be a 
class name, and you should also pass whatever other parameters your 
SslContextFactory expects (I'm not sure what they are in your case). 
This is more or less what's described in [2] for PkixSslContextFactory. 
Most of the "keyStore*" parameters also work for the 
DefaultSslContextFactory.


If you want to pass an SslContextFactory that has already been 
configured (perhaps with more advanced options), you might want to pass 
the instance via the "sslContextFactory" /attribute/ in the context, in 
which case the value of the "sslContextFactory" /parameter/ will be ignored.

This could look like this, for example:

import org.jsslutils.sslcontext.PKIXSSLContextFactory;
import org.jsslutils.sslcontext.trustmanagers.GsiWrappingTrustManager;

final PKIXSSLContextFactory sslContextFactory = new 
PKIXSSLContextFactory(..., ..., ...);
for (String crl :  ...) {
        sslContextFactory.addCrl(crl);
}

sslContextFactory.setTrustManagerWrapper(new 
GsiWrappingTrustManager.Wrapper());

server.getContext().getAttributes().put("sslContextFactory",
        new SslContextFactory() {
                @Override
                public SSLContext createSslContext() throws Exception {
                        return sslContextFactory.buildSSLContext();
                }

                @Override
                public void init(Series<Parameter> parameters) {
                }
        });



Best wishes,

Bruno.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1018944

Reply via email to