Index: sslguide.xml =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/xdocs/sslguide.xml,v retrieving revision 1.1 diff -u -r1.1 sslguide.xml --- sslguide.xml 12 Jun 2003 03:31:50 -0000 1.1 +++ sslguide.xml 12 Jun 2003 08:48:09 -0000 @@ -16,7 +16,7 @@ HttpClient provides full support for HTTP over Secure Sockets Layer (SSL) or IETF Transport Layer Security (TLS) protocols by leveraging the Java Secure Socket Extension (JSSE). JSSE has been integrated into the Java 2 platform as of - version 1.4 and usually should work with HttpClient out of the box. On older Java 2 versions JSSE + version 1.4 and works with HttpClient out of the box. On older Java 2 versions JSSE needs to be manually installed and configured. Installation instructions can be found here
@@ -25,7 +25,7 @@- With SSL properly set up and configured, secure HTTP communication over SSL should be as simple + Once you have JSSE correctly installed, secure HTTP communication over SSL should be as simple as plain HTTP communication.
- Per default HTTP client does not perform any custom certificate or certificate chain validation. - The default HTTPS protocol implementation is completely reliant upon the standard functionality - of the JSSE that comes with the JVM. If your application requires some additional processing of - credentials such certificate verification or certificate chain validation, or you want to be using - a third party SSL library, you can augment HttpClient to meet your specific requirements by providing - a custom protocol implementation. -
+ The default behaviour of HttpClient is suitable for most uses, however + there are some aspects which you may want to configure. The most common + requirements for customizing SSL are: + +SSLException with the message
+ Unrecognized SSL handshake (or similar) being thrown when a
+ connection attempt is made.+ Implementation of a custom protocol involves the following steps: +
-- Implementation of a custom protocol involves the following steps: -
++ Provide a custom socket factory that implements + + org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory interface. The socket + factory is responsible for opening a socket to the target server + using either the standard or a third party SSL library and + performing any required initialization such as performing the + connection handshake. Generally the initialization is performed + automatically when the socket is created. +
+- Provide a custom socket factory that implements - - org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory interface. The socket - factory should encapsulate application specific aspects of opening a socket to the target server - using either standard or third party SSL library. -
-+ Instantiate an object of type + org.apache.commons.httpclient.protocol.Protocol. The new instance + would be created with a valid URI protocol scheme (https in this + case), the custom socket factory (discussed above) and a default port + number (typically 443 for https). For example: +
-- Instantiate an object of type - org.apache.commons.httpclient.protocol.Protocol. The new instance would be initialized with the - following parameters: valid URI protocol scheme (https in this case), custom socket factory discussed - above, and a default port number. -
++ The new instance of protocol can then be set as the protocol handler + for a HostConfiguration. For example to configure the default host and + protocol handler for a HttpClient instance use: +
-- The resultant protocol object then can be used as a default protocol for a host. -
++ Finally, you can register your custom protocol as the default handler + for a specific protocol designator (eg: https) by calling the + Protocol.registerProtocol method. You can specify your own protocol + designator (such as 'myhttps') if you need to use your custom + protocol as well as the default SSL protocol implementation. +
-- Optionally register the custom protocol by calling Protocol.registerProtocol method. You can - specify your own protocol designator (such as 'myhttps') if you are going to be using this protocol - along with the default SSL protocol implementation. -
++ Once registered the protocol be used as a 'virtual' scheme inside target URIs. +
-- Once registered the protocol be used as a 'virtual' scheme inside target URIs. -
++ If you want this protocol to represent the default SSL protocol implementation, simply register + it under 'https' designator, which will make the protocol object take place of the existing one +
-- If you want this protocol to represent the default SSL protocol implementation, simply register - it under 'https' designator, which will make the protocol object take place of the existing one -
- -- There are several custom socket factories available in our contribution package. They can - be a good start for those who seek to tailor the behavior of the HTTPS protocol to the specific - needs of their application: -
++ There are several custom socket factories available in our contribution + package. They can be a good start for those who seek to tailor the + behavior of the HTTPS protocol to the specific needs of their + application: +
-Workaround: If persistent SSL connections support is an issue for your application we strongly advise you to upgrade to Java 1.4. @@ -214,9 +230,12 @@ breaking the existing APIs. The problem will be addressed in HttpClient release 2.1.
- Workaround: Use preemptive server authentication. Please note that only - BASIC authentication can be used preemptively. For more detailed information please refer - to the Authentication Guide. + Workaround: Use preemptive server authentication or + configure the server to keep the connection alive when returning an + authorization challenge. Please note that only + BASIC authentication can be used preemptively. For more detailed + information please refer to the + Authentication Guide.
- If you are unlucky and HTTPS with HttpClient does not work for you, it may be a bit premature - to blame it squarely on HttpClient. The JSSE is highly prone to configuration problems, especially - on older JVMs, which it is not an integral part of. + JSSE is prone to configuration problems, especially on older JVMs, + which it is not an integral part of. As such, if you do encounter + problems with SSL and HttpClient it is important to check that JSSE is + correctly installed.
- The application below can be used as an ultimate test that can reliably tell if SSL configured - properly, as it relies on a plain socket in order to communicate with the target server. If you - get an exception while executing this code, most certainly SSL is not functioning properly with - your JVM. Please refer to Sun's official resources for support or additional details on JSSE - configuration. + The application below can be used as an ultimate test that can reliably + tell if SSL configured properly, as it relies on a plain socket in + order to communicate with the target server. If an exception is thrown + when executing this code, SSL is not correctly installed and configured. + Please refer to Sun's official resources for support or additional + details on JSSE configuration.