JDK-4919790 : Errors in alert ssl message does not reflect the actual certificate status
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.net.ssl
  • Affected Version: 1.4.2,6,8,11
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_8,windows_xp
  • CPU: x86,sparc
  • Submitted: 2003-09-09
  • Updated: 2020-11-19
  • Resolved: 2019-02-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 13 JDK 8 Other
11.0.7-oracleFixed 13 b09Fixed 8u261Fixed openjdk8u272Fixed
Description

Name: gm110360			Date: 09/09/2003


FULL PRODUCT VERSION :
java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mod

FULL OS VERSION :
SunOS sun2 5.8 Generic sun4u sparc SUNW,Ultra-5_10

A DESCRIPTION OF THE PROBLEM :
for ssl Server Socket ,
when incoming a ssl client connection with an expiry certificate ,
it generates the right exception (java.security.cert.CertificateExpiredException) but the server sends an alert with value = certificate_unknown .
The right value is  certificate_expired

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
create an ssl server that requests the certificate for the client.
open a connection with the client with a expiry certificate.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the server has to send an alert with value =  certificate_expired
ACTUAL -
the server sends an alert with value =  certificate_unknown


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
create a key MYKEYSERVER in a keystore call MYKEYSTORESERVER :
create a key MYKEYSERVER in a keystore call MYKEYSTORECLIENT :

keytool -keystore MYKEYSTORESERVER -alias MYKEYSERVER -keypasswd 123456 -genkey -keyalg RSA
keytool -keystore MYKEYSTORECLIENT -alias MYKEYCLIENT -keypasswd 123456 -genkey -keyalg RSA

creating a class for ssl server :

    try {
        int port = 443;
        ServerSocketFactory ssocketFactory =SSLServerSocketFactory.getDefault();
        ServerSocket ssocket = ssocketFactory.createServerSocket(port);
        ssocket.setNeedClientAuth(true);
        Socket socket = ssocket.accept();
        InputStream in = socket.getInputStream();
        OutputStream out = socket.getOutputStream();
        byte br[] = new br[10];
        out.read(br);
        in.close();
        out.close();
    } catch(IOException e) {
    }

java -Djavax.net.ssl.keyStore=MYKEYSTORESERVER
-Djavax.net.ssl.keyStorePassword=123456 MYKEYSERVER
-Djavax.net.ssl.trustStore=MYKEYSTORECLIENT
-Djavax.net.ssl.trustStorePassword=123456

creating a client
    try {
        int port = 443;
        String hostname = "hostname";
        SocketFactory socketFactory = SSLSocketFactory.getDefault();
        Socket socket = socketFactory.createSocket(hostname, port);
        InputStream in = socket.getInputStream();
        OutputStream out = socket.getOutputStream();
        socket.startHandshake() ;
        out.write("hello".getBytes())
        in.close();
        out.close();
    } catch(IOException e) {
    }

java -Djavax.net.ssl.keyStore=MYKEYSTORECLIENT
-Djavax.net.ssl.keyStorePassword=123456 MYKEYCLIENT
-Djavax.net.ssl.trustStore=MYKEYSTORESERVER
-Djavax.net.ssl.trustStorePassword=123456


---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
not found :(
(Incident Review ID: 201562) 
======================================================================

Comments
Fix Request (11u) This fixes the simple issue in SSL, and keeps codebases in sync (I see 11.0.7-oracle). Patch applies cleanly to 11u, passes tier{1,2,3} tests.
14-02-2020

Simple and straightforward update, no new regression test.
14-02-2019

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon
02-09-2004

EVALUATION Seems to be a problem. getTrustedCerts(KeyStore) is only including things if they are within the validity period. Note, the command line should be something like this: java -Djavax.net.ssl.keyStore=MYKEYSTORESERVER -Djavax.net.ssl.keyStorePassword=123456 -Djavax.net.ssl.trustStore=MYKEYSTORECLIENT -Djavax.net.ssl.trustStorePassword=123456 templates java -Djavax.net.ssl.keyStore=MYKEYSTORECLIENT -Djavax.net.ssl.keyStorePassword=123456 -Djavax.net.ssl.trustStore=MYKEYSTORESERVER -Djavax.net.ssl.trustStorePassword=123456 -Djavax.net.debug=all templatec Because otherwise, the -D values are appearing after the class name, and are not being set correctly. The code wouldn't even compile as was given, so here's the cleaned up version. import java.io.*; import javax.net.*; import javax.net.ssl.*; public class templates { public static void main(String args[]) throws Exception { int port = 2001; ServerSocketFactory ssocketFactory = SSLServerSocketFactory.getDefault(); SSLServerSocket ssocket = (SSLServerSocket)ssocketFactory.createServerSocket(port); ssocket.setNeedClientAuth(true); Socket socket = ssocket.accept(); InputStream in = socket.getInputStream(); OutputStream out = socket.getOutputStream(); byte br[] = new byte [10]; in.read(br); in.close(); out.close(); } } import java.net.*; import java.io.*; import javax.net.*; import javax.net.ssl.*; public class templatec { public static void main(String args[]) throws Exception { int port = 2001; String hostname = "localhost"; SocketFactory socketFactory = SSLSocketFactory.getDefault(); SSLSocket socket = (SSLSocket) socketFactory.createSocket(hostname, port); InputStream in = socket.getInputStream(); OutputStream out = socket.getOutputStream(); socket.startHandshake() ; out.write("hello".getBytes()); in.close(); out.close(); } } ###@###.### 2003-09-09 There is no way for the Handshakers to communicate with the SSLEngine/SSLSockets as to the type of error it's seeing. It simply thrown a generic IOException, and they we take a best guess as to why the problem occured way away from the real cause. Need a alertCausedBy message. There are some RFC2246 7.2.2 error alerts we're not sending. For example, bad_certificate certificate_expired, certificate_unknown, unknown_ca, and so on. ###@###.### 2004-01-30 Duh, that's what fatal(description...) is for. What I don't know how we can work around is that the X509Managers simply throw SSLException, they don't necessarily give you detailed information about why things failed. ###@###.### 2004-02-05
05-02-2004