Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8326233

Utils#copySSLParameters loses needClientAuth Setting

    XMLWordPrintable

Details

    • b11
    • generic
    • generic

    Description

      A DESCRIPTION OF THE PROBLEM :
      The jdk.internal.net.http.common.Utils#copySSLParameters function calls `setNeedClientAuth` before `setWantClientAuth`. Both of these flags are mutually exclusive and when called, set the other value to false. Since `setWantClientAuth` is called after `setNeedClientAuth`, `needClientAuth` will always be `false`.

      This bug makes it impossible to create a HTTP client with `needClientAuth` set to `true`.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The code should not throw a RuntimeException since `needClientAuth` was set to `true`
      ACTUAL -
      The code throws a RuntimeException because `needClientAuth` is false after copying the SSLParameters object

      ---------- BEGIN SOURCE ----------
      package org.example;

      import javax.net.ssl.SSLParameters;
      import java.net.http.HttpClient;

      public class Reprod {
        public static void main(String[] args) {
          final var sslParams = new SSLParameters();
          sslParams.setNeedClientAuth(true);

          final var httpClient = HttpClient.newBuilder().sslParameters(sslParams).build();
          if (!httpClient.sslParameters().getNeedClientAuth()) {
            throw new RuntimeException();
          }
        }

      }
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              jpai Jaikiran Pai
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: