[ 
https://issues.apache.org/jira/browse/GEODE-8070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17102078#comment-17102078
 ] 

Bruce J Schuchardt edited comment on GEODE-8070 at 5/7/20, 10:40 PM:
---------------------------------------------------------------------

How about this?
{code:java}
  public static SSLContext getSSLContextInstance(SSLConfig sslConfig)
      throws NoSuchAlgorithmException {
    String[] protocols = sslConfig.getProtocolsAsStringArray();
    return findSSLContextForProtocols(protocols);
  }

  private static SSLContext findSSLContextForProtocols(final String[] 
protocols) throws NoSuchAlgorithmException {
    for (String protocol : protocols) {
      if (protocol.equalsIgnoreCase("any")) {
        // update the following list with new algorithms as they become 
available/wanted
        final String[] knownAlgorithms = {"TLSv1.3", "TLSv1.2", "TLSv1.1", 
"TLSv1", "SSLv3", "SSLv2", "SSL"};
        return findSSLContextForProtocols(knownAlgorithms);
      }
      try {
        return SSLContext.getInstance(protocol);
      } catch (NoSuchAlgorithmException e) {
        // continue
      }
    }
    throw new NoSuchAlgorithmException();
  }
{code}


was (Author: bschuchardt):
How about this?

{code}
  public static SSLContext getSSLContextInstance(SSLConfig sslConfig)
      throws NoSuchAlgorithmException {
    String[] protocols = sslConfig.getProtocolsAsStringArray();
    return findSSLContextForProtocols(protocols);
  }

  private static SSLContext findSSLContextForProtocols(final String[] 
protocols) throws NoSuchAlgorithmException {
    for (String protocol : protocols) {
      if (protocol.equalsIgnoreCase("any")) {
        // update the following list with new algorithms as they become 
available/wanted
        final String[] knownAlgorithms = {"TLSv1.3", "TLSv1.2", "TLSv1.1", 
"TLS", "SSLv3", "SSLv2", "SSL"};
        return findSSLContextForProtocols(knownAlgorithms);
      }
      try {
        return SSLContext.getInstance(protocol);
      } catch (NoSuchAlgorithmException e) {
        // continue
      }
    }
    throw new NoSuchAlgorithmException();
  }
{code}

> rework handling of "any" in SSLUtils
> ------------------------------------
>
>                 Key: GEODE-8070
>                 URL: https://issues.apache.org/jira/browse/GEODE-8070
>             Project: Geode
>          Issue Type: Bug
>          Components: membership
>            Reporter: Bruce J Schuchardt
>            Priority: Major
>
> SSLUtil has a list of "known" TLS protocols.  It should support TLSv1.3.
>  
> {noformat}
> // lookup known algorithms
> String[] knownAlgorithms = {"SSL", "SSLv2", "SSLv3", "TLS", "TLSv1", 
> "TLSv1.1", "TLSv1.2"};
> for (String algo : knownAlgorithms) {
>   try {
>     sslContext = SSLContext.getInstance(algo);
>     break;
>   } catch (NoSuchAlgorithmException e) {
>     // continue
>   }
> } {noformat}
> We probably can't fully test this change since not all JDKs we test with 
> support v1.3 at this time.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to