[an error occurred while processing this directive] [an error occurred while processing this directive]
[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]

JSSE Documentation

Related Documentation
  1. API Documentation
  2. JSSE FAQ
  3. JSEE API Users Guide

Common Questions


Q: My JSSE program gives one of the following errors:
Exception in thread "main" java.net.SocketException: no SSL Server Sockets
Exception in thread "main" java.net.SocketException: SSL implementation not available
A: You must register the Cryptographic Service Provider in your code, as detailed in the API Users Guide. To do so, add the following lines to your program:
import java.security.*;
with the other import statements and
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
after the declaration of main. See below a working example of the URLReader.java sample (more samples can be found in /usr/local/pkg/jsse). Also notice the System.setProperty call which is required. See the API Users Guide and API Documentation for more information.
/*
 * @(#)URLReader.java	1.1 99/10/06
 *
 * Copyright 1995-1998 by Sun Microsystems, Inc.,
 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Sun Microsystems, Inc. ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Sun.
 */
import java.net.*;
import java.io.*;
import java.security.*;


/*
 * This example illustrates using a URL to access resources
 * on a secure site.
 *
 * To use Sun's reference implementation of HTTPS protocol, Please set
 * the following Java system property:
 *
 *    java.protocol.handler.pkgs = com.sun.net.ssl.internal.www.protocol
 *
 * If you are running inside a firewall, please also set the following
 * Java system properties to the appropriate value:
 *
 *   https.proxyHost = 
 *   https.proxyPort = 
 *
 */

public class URLReader {
    public static void main(String[] args) throws Exception {

        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

	System.setProperty("java.protocol.handler.pkgs",
	"com.sun.net.ssl.internal.www.protocol");

	URL verisign = new URL("https://www.verisign.com/");
	BufferedReader in = new BufferedReader(
				new InputStreamReader(
				verisign.openStream()));

	String inputLine;

	while ((inputLine = in.readLine()) != null)
	    System.out.println(inputLine);

	in.close();
    }
}


Q: My program gives the following error:
Exception in thread "main" java.net.MalformedURLException: unknown protocol: https

A: You must specify an implementation of the HTTPS protocol by including the following line in your code:
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
See above for an example. See the API Users Guide for more information.
[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]