VirtualBox

Changeset 53219 in vbox for trunk/src/VBox/Main/glue


Ignore:
Timestamp:
Nov 4, 2014 7:02:36 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96767
Message:

Main/glue/glue-java.xsl: make the jax-ws API binding use TLS only, which needs a lot of code to work around a bug in the usual SSLSocketFactory, which happily tries SSLv2 HELLO even for a TLS SSLContext. Setting a custom SSLSocketFactory needs tweaking non-portable bindings, which might break the whole code which don't provide these.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/glue-java.xsl

    r51448 r53219  
    42424242import java.util.Map;
    42434243import java.util.HashMap;
     4244import java.util.ArrayList;
    42444245import javax.xml.namespace.QName;
    42454246import javax.xml.ws.BindingProvider;
    42464247import javax.xml.ws.Holder;
    42474248import javax.xml.ws.WebServiceException;
     4249import java.io.IOException;
     4250import java.net.UnknownHostException;
     4251import java.net.Socket;
     4252import java.net.InetAddress;
     4253import javax.net.SocketFactory;
     4254import javax.net.ssl.SSLContext;
     4255import javax.net.ssl.SSLSocketFactory;
     4256import javax.net.ssl.SSLSocket;
    42484257
    42494258class PortPool
     
    43614370
    43624371
     4372class VBoxTLSSocketFactory extends SSLSocketFactory
     4373{
     4374    private final SSLSocketFactory sf;
     4375
     4376    private void setupSocket(SSLSocket s)
     4377    {
     4378        String[] oldproto = s.getEnabledProtocols();
     4379        List<String> protolist = new ArrayList<String>();
     4380        for (int i = 0; i < oldproto.length; i++)
     4381            if (oldproto[i].toUpperCase().startsWith("TLS"))
     4382                protolist.add(oldproto[i]);
     4383        String[] newproto = protolist.toArray(new String[protolist.size()]);
     4384        s.setEnabledProtocols(newproto);
     4385    }
     4386
     4387    public VBoxTLSSocketFactory()
     4388    {
     4389        SSLSocketFactory tmp = null;
     4390        try
     4391        {
     4392            SSLContext sc = SSLContext.getInstance("TLS");
     4393            sc.init(null, null, null);
     4394            tmp = sc.getSocketFactory();
     4395        }
     4396        catch (Exception e)
     4397        {
     4398            e.printStackTrace();
     4399        }
     4400        sf = tmp;
     4401    }
     4402
     4403    public static SocketFactory getDefault()
     4404    {
     4405        return new VBoxTLSSocketFactory();
     4406    }
     4407
     4408    public Socket createSocket(Socket socket, String host, int port,
     4409                               boolean autoClose) throws IOException, UnknownHostException
     4410    {
     4411        SSLSocket s = (SSLSocket)sf.createSocket(socket, host, port, autoClose);
     4412        setupSocket(s);
     4413        return s;
     4414    }
     4415
     4416    public Socket createSocket() throws IOException
     4417    {
     4418        SSLSocket s = (SSLSocket)sf.createSocket();
     4419        setupSocket(s);
     4420        return s;
     4421    }
     4422
     4423    public Socket createSocket(InetAddress host, int port) throws IOException
     4424    {
     4425        SSLSocket s = (SSLSocket)sf.createSocket(host, port);
     4426        setupSocket(s);
     4427        return s;
     4428    }
     4429
     4430    public Socket createSocket(InetAddress address, int port,
     4431                               InetAddress localAddress, int localPort) throws IOException
     4432    {
     4433        SSLSocket s = (SSLSocket)sf.createSocket(address, port, localAddress, localPort);
     4434        setupSocket(s);
     4435        return s;
     4436    }
     4437
     4438    public Socket createSocket(String host, int port) throws IOException, UnknownHostException
     4439    {
     4440        SSLSocket s = (SSLSocket)sf.createSocket(host, port);
     4441        setupSocket(s);
     4442        return s;
     4443    }
     4444
     4445    public Socket createSocket(String host, int port,
     4446                               InetAddress localHost, int localPort) throws IOException, UnknownHostException
     4447    {
     4448        SSLSocket s = (SSLSocket)sf.createSocket(host, port, localHost, localPort);
     4449        setupSocket(s);
     4450        return s;
     4451    }
     4452
     4453    public String[] getDefaultCipherSuites()
     4454    {
     4455        return sf.getSupportedCipherSuites();
     4456    }
     4457
     4458    public String[] getSupportedCipherSuites()
     4459    {
     4460        return sf.getSupportedCipherSuites();
     4461    }
     4462}
     4463       
     4464
    43634465public class VirtualBoxManager
    43644466{
     
    43874489            ((BindingProvider)port).getRequestContext().
    43884490                put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
     4491            VBoxTLSSocketFactory sf = new VBoxTLSSocketFactory();
     4492            ((BindingProvider)port).getRequestContext().
     4493                put("com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory", sf);
     4494
    43894495            String handle = port.iWebsessionManagerLogon(username, passwd);
    43904496            this.vbox = new IVirtualBox(handle, port);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette