You need to write a host name verifier that validates the host.
A host name verifier validates that the host to which an SSL connection is made is the intended or authorized party. In an Endeca JSP application, you use the AuthHttpENEConnection.setHostnameVerifier() method to set the host name verifier. Because this method takes a javax.sun.net.ssl.HostnameVerifier object type , you must create your own HostnameVerifier class.
During testing, you may want to use a null version of the HostnameVerifier class, which always returns true. The Java code for such a class is used in the example below. In a production environment, you would want to write a class that actually verifies that the host name is an acceptable match with the server's authentication scheme.
To write and implement your HostnameVerifier class:
package myverifier;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
/**
* Create a class to trust all hosts, so always returns true
*/
public class NullHostnameVerifier implements HostnameVerifier {
public boolean verify(String urlHostname, SSLSession sslSession) {
return true;
}
}
javac NullHostnameVerifier.java
C:\Tomcat\webapps\endeca_jspref\WEB-INF\classes\myverifier
<%@ page errorPage="error.jsp" %> <%@ page import="com.endeca.navigation.*" %> <%@ page import="com.endeca.logging.*" %> <%@ page import="myverifier.NullHostnameVerifier" %>
//Instantiate a connection object for the MDEX Engine AuthHttpENEConnection nec = new AuthHttpENEConnection(eneHost, enePort); // Enable the SSL connection with our NullHostnameVerifier class nec.setHostnameVerifier(new NullHostnameVerifier());