<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Michael Tandy wrote:
<blockquote
 cite="mid:302aa0340903030655j5a333315xb62320c267bf29e3@mail.gmail.com"
 type="cite">
  <blockquote type="cite">
    <pre wrap="">While in a public DNS server, 172.127.192.1 is assigned to "dummy.sun.com".
It is possible that the getLocalHostname() would return
"the_actual_name_is_dummy_sun_com", which getCanonicalHostName() would
return "dummy.sun.com".

Because the certificate matching the hostname will be used used by remote
peer, instead of the local host. So "the_actual_name_is_dummy_sun_com" means
trouble to the remote side, which has no way to identify it, it is a local
setting of remote side. So we have to use getCanonicalHostName() here.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
So the secure server's host name has to be the canonical host name?

e.g. if one IP address hosted both <a class="moz-txt-link-freetext" href="http://www.example.com">http://www.example.com</a> and
<a class="moz-txt-link-freetext" href="https://secure.example.com">https://secure.example.com</a> the canonical host name for the IP address
would have to be secure.example.com for the right certificate to be
identified, or the SSL server would have to have only one certificate?

  </pre>
</blockquote>
Yes. The canonical hostname should be secure.example.com, or the
certificate SubjectAlterName should be of "*.example.com". Otherwise,
which certificate would be selected from key store is unable to
expected. So it is not a solution for virtual hosts on the same IP
address, which would be addressed by SNI.<br>
<br>
Thanks,<br>
Xuelei<br>
<blockquote
 cite="mid:302aa0340903030655j5a333315xb62320c267bf29e3@mail.gmail.com"
 type="cite">
  <pre wrap=""></pre>
  <blockquote type="cite">
    <pre wrap="">2. If a client application run on a box with multiple physical network
adapters and share a key store, it is also required to figure out the right
certificate from multiple for a certain connection.
  The fix can do that. But SNI cannot. SNI is a ClientHello extension, send
by client side. The server side CertificateRequest message has no such
mechanism.

So I think we need the enhancement, because SNI cannot meet all of the
requirement above.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
I see what you mean! I was just thinking of using your fix for this
bug as an example of how we might implement SNI in the future.

  </pre>
  <blockquote type="cite">
    <pre wrap="">BTW, could I cc to <a class="moz-txt-link-abbreviated" href="mailto:security-dev@openjdk.java.net">security-dev@openjdk.java.net</a>?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Done.

Michael


2009/3/3 Xuelei Fan <a class="moz-txt-link-rfc2396E" href="mailto:Xuelei.Fan@sun.com"><Xuelei.Fan@sun.com></a>:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Michael Tandy wrote:
    </pre>
    <blockquote type="cite">
      <pre wrap="">I was wondering - I see you get the host name using:

InetAddress localAddress = socket.getLocalAddress();
hostname = localAddress.getCanonicalHostName();

then you send a certificate matching hostname.

What would be the implications of using getHostName instead of
getCanonicalHostName?
      </pre>
    </blockquote>
    <pre wrap="">For example, in my working spac box, I would config my /etc/hosts similar
to:
172.127.192.1 the_actual_name_is_dummy_sun_com

While in a public DNS server, 172.127.192.1 is assigned to "dummy.sun.com".
It is possible that the getLocalHostname() would return
"the_actual_name_is_dummy_sun_com", which getCanonicalHostName() would
return "dummy.sun.com".

Because the certificate matching the hostname will be used used by remote
peer, instead of the local host. So "the_actual_name_is_dummy_sun_com" means
trouble to the remote side, which has no way to identify it, it is a local
setting of remote side. So we have to use getCanonicalHostName() here.
    </pre>
    <blockquote type="cite">
      <pre wrap=""> I'm thinking we could implement SNI by
overriding the socket's getLocalAddress to send an InetAddress with
the hostname set to the SNI-requested server name, then your code
would select the best key automatically.


      </pre>
    </blockquote>
    <pre wrap="">Yes, that's the benefits of SNI extension. To make myself understood, let's
look at the requirements of the enhancement , which is different from SNI.
1. the environment of the bug reported against is: several servers run on a
single physical box, which has more than one physical network adapters, and
configured each with different IP address and different certificate. However
the servers want to share a keystore, all certificates are stored into the
same keystore. That means in the keystore, there are multiple key entries
could be used, it is required to select the right one for a certain
connection.
  If the client hello message include a SNI extension, it is the primary
function to select one certificate from multiple.for a SNI support server.
You're right here.
   However if the client hello message does not include the SNI, we should
also be able find the right certificate out. That's the benefit of the fix.

2. If a client application run on a box with multiple physical network
adapters and share a key store, it is also required to figure out the right
certificate from multiple for a certain connection.
  The fix can do that. But SNI cannot. SNI is a ClientHello extension, send
by client side. The server side CertificateRequest message has no such
mechanism.

So I think we need the enhancement, because SNI cannot meet all of the
requirement above.

Thanks very much for looking into this.

BTW, could I cc to <a class="moz-txt-link-abbreviated" href="mailto:security-dev@openjdk.java.net">security-dev@openjdk.java.net</a>?

Thanks,
Xuelei
    </pre>
    <blockquote type="cite">
      <pre wrap="">Or would we be better waiting until the next JDK version and defining
a clearer way of passing the host name?

Michael


2009/2/27 Xuelei Fan <a class="moz-txt-link-rfc2396E" href="mailto:Xuelei.Fan@sun.com"><Xuelei.Fan@sun.com></a>:

      </pre>
      <blockquote type="cite">
        <pre wrap="">I need to get a code review for:
   4773451 Support IP address based virtual hosting in default KeyManager
implementation

<a class="moz-txt-link-freetext" href="http://cr.openjdk.java.net/~xuelei/4773451/webrev.00/">http://cr.openjdk.java.net/~xuelei/4773451/webrev.00/</a>
<a class="moz-txt-link-rfc2396E" href="http://cr.openjdk.java.net/%7Exuelei/4773451/webrev.00/"><http://cr.openjdk.java.net/%7Exuelei/4773451/webrev.00/></a>

Thanks,
Xuelei

The  bug description:
-------------------------------------------------
When using multiple SSLServerSockets with each listening on
it's own IP address, the JVM is not correctly sending the
correct certificate to the connecting client's web browser.
Regardless of which domain/IP the browser attempts to
connect to, the JVM always maps the domain/IP for the first
listed certificate in the keystore.

Example:  domains abc.com, def.com, ghi.com each have their
own self-signed certificate in keystore , each created using
'keytool -genkey' and created in same order.  Each also
being domain mapped to their own IP address and served
through their own SSLServerSocket.

When a client attempts to connect to abc.com, all is well.
The correct certificate is presented to the client and
connection succeeds.  However, when the client attempt to
connect to either def.com or ghi.com, they are presented
with the certificate for abc.com.

If client connecting to def.com or ghi.com elects to accept
that incorrect certificate, connection succeeds to proper
site, despite use of incorrect certificate.  So correct
domain/IP mapping is not the issue.



        </pre>
      </blockquote>
    </blockquote>
    <pre wrap="">
    </pre>
  </blockquote>
</blockquote>
<br>
</body>
</html>