<div dir="ltr"><div>Hi Xuelei,</div><div><br></div><div>The new webrev.02 is ready:</div><div><br></div><div> * <a href="http://people.redhat.com/mbalaoal/webrevs/jdk_8046295_trusted_ca/2017_06_15/8046295.webrev.02/">http://people.redhat.com/mbalaoal/webrevs/jdk_8046295_trusted_ca/2017_06_15/8046295.webrev.02/</a> (browse online)</div><div> * <a href="http://people.redhat.com/mbalaoal/webrevs/jdk_8046295_trusted_ca/2017_06_15/8046295.webrev.02.zip">http://people.redhat.com/mbalaoal/webrevs/jdk_8046295_trusted_ca/2017_06_15/8046295.webrev.02.zip</a> (zip, download)</div><div><br></div><div>The following changes have been implemented since the previous webrev.01:</div><div><br></div><div> * s/getUseTrustedCAIndication() methods in SSLEngine/SSLSocket and in SSLEngineImpl/SSLSocketImpl removed. s/getSSLParameters is now the only way to set or get the use of the Trusted CA Indication extension. An exception is no longer thrown if trying to disable the extension for a server, but the change takes no effect as the extension is mandatory for servers. X509KeyManagerImpl modified to use SSLParameters to get information regarding if Trusted CA Indication is enabled and should guide the certificate choice.</div><div><br></div><div> * TrustedAuthorityIndicator.IdentifierType has been moved from enum to String, to follow JSSE conventions. I understand how important is to be consistent. However, I still believe that an enum is a better fit for this value and does not prevent from future extension. We are choosing from a closed set (strictly defined by the RFC) and that's what enum allows to express. From the client point of view/API, it's very handy that the type gives you information regarding the allowed choices for the parameter. You don't necessarily have to look for implementation details or documentation but you can just leverage on the strongly typed language. It's also likely that enums are faster for comparisons than strings, but that's not the main point here.</div><div><br></div><div> * Removed X509Certificate from TrustedAuthorityIndicator class (method and property). It was there for informational purposes (when TrustedAuthorityIndicator was built from a certificate by a client and the whole extension indicators converted to String). </div><div><br></div><div> * "equals" and "hashCode" methods moved from TrustedAuthorityIndicator to TrustedAuthorityIndicatorImpl class.</div><div><br></div><div> * "getLength" method removed from TrustedAuthorityIndicator class. It's possible to get the encoded buffer and the length from there.</div><div><br></div><div> * "getData" method renamed to "getEncoded" in TrustedAuthorityIndicator class.</div><div><br></div><div> * "trustedAuthorityEncodedData" renamed to "encodedData" in TrustedAuthorityIndicator and TrustedAuthorityIndicatorImpl classes</div><div><br></div><div> * "identifier" and "encodedData" instance variables moved from TrustedAuthorityIndicator to TrustedAuthorityIndicatorImpl class.</div><div><br></div><div> * "getEncoded" and "getIdentifier" are now abstract methods in TrustedAuthorityIndicator, and their implementation is in TrustedAuthorityIndicatorImpl class.</div><div><br></div><div> * "getIdentifier" method renamed to "getType" in TrustedAuthorityIndicator and TrustedAuthorityIndicatorImpl classes ("identifier" instance variable and parameter in TrustedAuthorityIndicatorImpl class renamed to "type").</div><div><br></div><div> * Test cases (server and client) updated to reflect the new interface (enabling the use of the extension through SSLParameters)</div><div><br></div><div>However, some changes are still not implemented and I have some concerns:</div><div><br></div><div>1) I still believe that identifier type information has to be on TrustedAuthorityIndicator class somehow, and implementations restricted on what they can return as part of "getType" method. This is strictly specified by the RFC TrustedAuthorityIndicator class represents, and I find desirable that any implementation is enforced to be compliant to that. If we remove all of that (including the enum), TrustedAuthorityIndicator looks too generic and does not reflect (in my opinion) what it really is. It'd also be chaotic if different implementations call pre-agreed type as "preagreed", "pre-agreed", "PRE_AGREED", etc. I prefer stricter and more explicit interfaces.</div><div><br></div><div>2) I agree that type mappings can be seen as part of an implementation, but they were in TrustedAuthorityIndicator (as protected) because every implementation is highly likely to need them and we can avoid the necessity for repeated code/mappings. The same for "type" and "encodedData" variables or even "hashCode" and "equals" methods. That's why I was thinking more of an abstract class and not an interface, as it happens (in example) with SNIServerName.</div><div><br></div><div>3) I think that "implies" method on TrustedAuthorityIndicator should be also part of the class/interface, because that's the whole point of a Trusted Authority Information: to allow queries for a given certificate. This is, in fact, the only thing a server wants from one of these objects. My concern is that if we remove this requirement for an implementation, the interface looks more like a byte buffer holder.</div><div><br></div><div>I'd appreciate if you can re-consider these items.</div><div><br></div><div>Thanks,</div><div>Martin.-</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 14, 2017 at 7:17 PM, Xuelei Fan <span dir="ltr"><<a href="mailto:xuelei.fan@oracle.com" target="_blank">xuelei.fan@oracle.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Martin,<br>
<br>
The big picture of the design looks pretty good to me, except a few comment about the JSSE conventions.  I appreciate it very much.  By the way, I need more time to look into the details of the specification and implementation.<br>
<br>
<br>
In order to keep the APIs simple and small, SSLParameters is preferred as the only configuration port for common cases.   I may suggest to remove the s/getUseTrustedCAIndication() methods in SSLEngine/SSLSocket.<br>
<br>
The identify type is defined as an enum TrustedAuthorityIndicator.Iden<wbr>tifierType.  In the future, if more type is added, we need to update the specification by adding a new enum item.  Enum is preferred in JDK, but for good extensibility, in general JSSE does not use enum in public APIs for extensible properties.  I may suggest to use String (or integer/byte, I prefer to use String) as the type.  The standard trusted authority indicator algorithm (identifier) can be documented in the "Java Cryptography Architecture Standard Algorithm Name Documentation"[1].<br>
<br>
In TrustedAuthorityIndicator class, some methods, like getIdentifierTypeFromCode(), getCodeFromIdentifierType(), implies(), getLength(), equals() and hashCode() look more like implementation logic.  I may suggest remove them from public APIs.<br>
<br>
I did not see the benefit to have X509Certificate in the TrustedAuthorityIndicator class.  The class is mainly used for server side certificate selection.  X509Certificate could be unknown for a indicator.  I may suggestion remove the related methods and properties.<br>
<br>
After that, as there is no requirement to instantiate TrustedAuthorityIndicator class in application code, looks like it may be enough to use an interface to represent a trusted authorities:<br>
   public interface TrustedAuthorityIndicator {<br>
        // identifier type, standard algorithm name<br>
        String/int/Byte getType();<br>
<br>
        // identifier<br>
        byte[] getEncoded();<br>
   }<br>
<br>
What do you think?<br>
<br>
<br>
Thanks & Regards,<br>
Xuelei<br>
<br>
[1] <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html" rel="noreferrer" target="_blank">https://docs.oracle.com/javase<wbr>/8/docs/technotes/guides/<wbr>security/StandardNames.html</a><span class=""><br>
<br>
<br>
On 6/13/2017 3:41 PM, Martin Balao wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Xuelei,<br>
<br><span class="">
The new webrev.01 is ready:<br>
<br>
  * <a href="http://people.redhat.com/mbalaoal/webrevs/jdk_8046295_trusted_ca/2017_06_13/8046295.webrev.01/" rel="noreferrer" target="_blank">http://people.redhat.com/mbala<wbr>oal/webrevs/jdk_8046295_truste<wbr>d_ca/2017_06_13/8046295.webrev<wbr>.01/</a> (browse online)<br>
  * <a href="http://people.redhat.com/mbalaoal/webrevs/jdk_8046295_trusted_ca/2017_06_13/8046295.webrev.01.zip" rel="noreferrer" target="_blank">http://people.redhat.com/mbala<wbr>oal/webrevs/jdk_8046295_truste<wbr>d_ca/2017_06_13/8046295.webrev<wbr>.01.zip</a> (zip, download)<br>
<br>
The following changes have been implemented since the previous webrev.00:<br>
<br>
  * Pre-agreed support removed from server-side<br>
   * Unnecessary overhead and minium benefits for JSSE.<br>
<br>
  * Enabling the use of Trusted CA Indication extension for clients through TrustManager objects was reverted. Trusted CA Indication extension can now be enabled through: 1) SSLEngine, 2) SSLSocket, or 3) SSLParameters (which can be applied to both SSLEngine and SSLSocket objects). Trusted CA Indication extension is mandatory for servers.<br>
<br>
  * SunX509KeyManagerImpl old key manager ("SunX509" algorithm) is now out of scope. This key manager does not support other TLS extensions as Server Name Indication (SNI), which is far more relevant than Trusted CA Indication. The new X509KeyManagerImpl key manager ("PKIX" algorithm) is now in scope.<br>
<br>
  * Client requested indications are now an ExtendedSSLSession attribute. ServerHandshaker gets the information from the Client Hello message (now parsed by TrustedCAIndicationExtension class instead of TrustedAuthorityIndicator) and sets it in the ExtendedSSLSession (SSLSessionImpl object). The key manager (i.e.: X509KeyManagerImpl), when choosing a server alias, may now get the information from the ExtendedSSLSession object and guide the certificate selection based on it.<br>
   * In order to allow multiple key managers to use Trusted Authority Indicators information and to allow multiple Trusted Authority Indicators implementations, TrustedAuthorityIndicator has now been split in an abstract class (TrustedAuthorityIndicator, located in javax.net.ssl) and an implementation class (TrustedAuthorityIndicatorImpl<wbr>, located in sun.security.ssl). No coupling was added between javax.net.ssl and sun.security.ssl packages.<br>
<br>
  * Documentation extended and improved.<br>
  * Test cases (server and client) updated to reflect the new interface and supported key manager.<br>
<br>
Look forward to your new review!<br>
<br>
Kind regards,<br>
Martin.-<br>
<br>
<br>
<br></span><div><div class="h5">
On Fri, Jun 9, 2017 at 6:15 PM, Xuelei Fan <<a href="mailto:xuelei.fan@oracle.com" target="_blank">xuelei.fan@oracle.com</a> <mailto:<a href="mailto:xuelei.fan@oracle.com" target="_blank">xuelei.fan@oracle.com</a>><wbr>> wrote:<br>
<br>
    I'm OK to use SSLParameters.  Thank you very much for considering a<br>
    new design.<br>
<br>
    Xuelei<br>
<br>
    On 6/9/2017 1:10 PM, Martin Balao wrote:<br>
<br>
        Hi Xuelei,<br>
<br>
        I didn't notice that some of the SSLSocket contructors did not<br>
        establish the connection, so SSLParameters can be effective for<br>
        Trusted CA Indication. This was an invalid argument on my side,<br>
        sorry.<br>
<br>
        As for the configuration to enable the extension, it's probably<br>
        not necessary on the Server side because -as you mentioned- it<br>
        is mandatory and there is no harm in supporting it. However, it<br>
        has to be configurable on the Client side because -as we<br>
        previously discussed- the client may cause a handshake failure<br>
        if the server does not support the extension. I'd prefer the<br>
        Client configuring the SSLSocket through SSLParameters instead<br>
        of a system-wide property -which has even more impact than the<br>
        TrustManager approach-. Would this work for you?<br>
<br>
          > In JSSE, the benefits pre_agreed option can get by<br>
        customizing the key/trust manager, so I did not see too much<br>
        benefits to support this option in JDK<br>
<br>
        I understand your point and will remove support for "pre_agreed".<br>
<br>
<br>
        On Fri, Jun 9, 2017 at 1:37 AM, Xuelei Fan<br>
        <<a href="mailto:xuelei.fan@oracle.com" target="_blank">xuelei.fan@oracle.com</a> <mailto:<a href="mailto:xuelei.fan@oracle.com" target="_blank">xuelei.fan@oracle.com</a>><br></div></div>
        <mailto:<a href="mailto:xuelei.fan@oracle.com" target="_blank">xuelei.fan@oracle.com</a> <mailto:<a href="mailto:xuelei.fan@oracle.com" target="_blank">xuelei.fan@oracle.com</a>><wbr>>><span class=""><br>
        wrote:<br>
<br>
<br>
<br>
             On 6/8/2017 8:36 PM, Xuelei Fan wrote:<br>
<br>
                 The trusted authorities can be get from client trust<br>
        manager.         Server can choose the best matching of server<br>
        certificate of the<br>
                 client requested trusted authorities.<br>
<br>
             ><br>
             I missed the point that the key manager need to know the client<br>
             requested trusted authorities for the choosing.  So may<br>
        need a new<br>
             SSLSession attribute (See similar method in<br>
        ExtendedSSLSession).<br>
<br>
             Xuelei<br>
<br>
<br>
<br>
        Yes, an attribute on SSLSession may do the job (both when Key<br>
        Manager receives a SSLSocket and a SSLEngine).<br>
<br>
        Kind regards,<br>
        Martin.-<br>
<br>
<br>
</span></blockquote>
</blockquote></div><br></div>