Questions and Answers
Using JSSE, developers can provide for the passage of secure data between a client and a server running any application protocol (such as HTTP, Telnet, NNTP, and FTP) over TCP/IP. JSSE will enable data encryption, server authentication, message integrity, and optional client authentication for a TCP/IP connection.
A non-commercial implementation typically lacks the overall completeness of a commercial-grade product. While the implementation meets the API specification, it will be lacking things such as a fully-featured toolkit, sophisticated debugging tools, commercial-grade documentation and regular maintenance updates.
A: JSSE 1.0.2 has been classified as an ENC/Retail product by the U.S. Department of Commerce Bureau of Export Affairs. This license exception means that JSSE may be freely exported, without any additional approval, with strong encryption, to all nations except for those specifically denied.
The following countries may not receive ANY US-developed encryption items: Afghanistan, Cuba, Iran, Iraq, Libya, North Korea, Serbia/Montenegro (Yugoslavia), Sudan, Syria and parties listed on the Denied and Restricted Parties List. Additionally, it is Sun company policy to not ship products to Burma.
java -Djavax.net.debug=help SomeClass
Problem: When compiling a program that uses the JSSE 1.0.2 packages, one of the following errors occur:
Package com.sun.net.ssl not found in import. Package javax.net not found in import. Package javax.net.ssl not found in import. Package javax.security.cert not found in import.Cause: The JSSE JAR files are not installed properly.
Solution: JSSE 1.0.2 is supplied as an extension to the Java 2 platform. Its JAR files can be installed either as "installed" extensions (recommended) or as "bundled" extensions. A JAR file is considered an "installed" extension if it is stored in a particular directory established for all installed extensions, as described in http://java.sun.com/products/jsse/install.html, and no class path modifications are needed. "Bundled" extensions may be bundled with applications or made available in a separate directory. If they are bundled with an application, be sure to specify them in the Class-Path attribute in the application's manifest file. Otherwise, be sure to set the Java
CLASSPATH
variable correctly so the JSSE JAR files can be found. For more information about bundled extensions, see Bundled Extensions.
Problem: When running a program that uses JSSE 1.0.2, an exception occurs indicating that an SSL service is not available. For example, an exception similar to one of the following occurs:
Exception in thread "main" java.net.SocketException: no SSL Server Sockets Exception in thread "main": SSL implementation not availableCause 1: The cryptographic service provider is not registered properly.
Solution 1: Before using JSSE 1.0.2, you must register the
SunJSSE
provider, either statically by modifying thejava.security
file or dynamically by calling theSecurity.addProvider
method, as described in http://java.sun.com/products/jsse/install.html.Cause 2: There was a problem with
SSLContext
initialization, for example due to a corrupted keystore. (Note: One vendor has shipped a keystore in an unknown format, and that may cause this type of error.)Solution 2: Check initialization parameters. Ensure any keystores specified are valid (e.g., by trying to use the keytool to examine them).
Problem: When negotiating an SSL connection, the client or server throws one of the following exceptions:
javax.net.ssl.SSLException: untrusted server cert chain javax.net.ssl.SSLException: untrusted client cert chainCause 1: This is generally caused by the remote side sending a certificate that is unknown to the local side.
Solution 1: The best way to debug this type of problem is to turn on debugging and watch as certificates are loaded and when certificates are received via the network connection. Most likely, the received certificate is unknown to the trust mechanism because the wrong trust file was loaded.
Cause 2: The system clock is not set correctly.
Solution 2: If the clock is not set correctly, the perceived time may be outside the validity period on one of the certificates, and unless the certificate can be replaced with a valid one from a truststore, the system must assume that the certificate is invalid, and therefore throw the exception.
Cause 3: Older versions of Java 2 Enterprise Edition use earlier versions of JSSE. In particular, some previous versions of J2EE shipped with JSSE 1.0, which couldn't replace received expired certificates with current ones from a truststore.
Solution 3: Be sure that the new JSSE jar files occur in the class path(s) ahead of any older J2EE jar files.
Problem: When running a program that uses JSSE 1.0.2, an exception occurs indicating that a JSSE class definition cannot be found. For example, an exception similar to the following occurs:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/net/ssl/SSLServerSocketFactoryCause: The JSSE JAR files are not installed properly.
Solution: JSSE must be installed as an extension to the Java 2 Platform. Install the JSSE JAR files as discussed in the Solution to the JSSE Package Not Found During Compilation problem shown above.
Problem: When using Netscape Navigator or Microsoft Internet Explorer (IE) to access files on a server that only has DSA-based certificates, a runtime exception occurs indicating that there are no cipher suites in common.
Cause: By default, certificates created with keytool use DSA public keys. Navigator and IE do not use DSA public keys in their enabled cipher suites.
Solution: To interact with Navigator or IE, you should create certificates that use RSA-based keys. To do this, you need to specify the
-keyalg
RSA option when using keytool. For example:keytool -genkey -alias duke -keystore testkeys -keyalg rsa