Java 如何为MarkLogic 7建立SSL连接?
我想建立一个SSL连接,如Java 如何为MarkLogic 7建立SSL连接?,java,marklogic,Java,Marklogic,我想建立一个SSL连接,如http://docs.marklogic.com/guide/admin/SSL 但我得到了以下例外: 线程“main”中出现异常 com.marklogic.xcc.exceptions.ServerConnectionException:无法识别 SSL消息,明文连接?[会话:user=demo,cb=Arg [ContentSource:user=demo,cb=Arg[provider:SSLconn 地址=localhost/127.0.0.1:9470,池
http://docs.marklogic.com/guide/admin/SSL
但我得到了以下例外:
线程“main”中出现异常
com.marklogic.xcc.exceptions.ServerConnectionException:无法识别
SSL消息,明文连接?[会话:user=demo,cb=Arg
[ContentSource:user=demo,cb=Arg[provider:SSLconn
地址=localhost/127.0.0.1:9470,池=0/64]][客户端:XCC/7.0-2]
在
com.marklogic.xcc.impl.handlers.AbstractRequestController.runRequest(AbstractRequestController.java:124)
在
com.marklogic.xcc.impl.SessionImpl.submitRequestInternal(SessionImpl.java:388)
在
com.marklogic.xcc.impl.SessionImpl.submitRequest(SessionImpl.java:371)
在com.demoe2.MarklogicDemo.main(MarklogicDemo.java:41)上,由以下原因引起:
javax.net.ssl.SSLException:无法识别的ssl消息,纯文本
联系?在
sun.security.ssl.EngineInputRecord.bytesInCompletePacket(未知
来源)位于sun.security.ssl.SSLEngineImpl.readNetRecord(未知
源)位于sun.security.ssl.SSLEngineImpl.unwrap(未知源)
我的源代码是Java的
public class MarklogicDemo {
public static void main(String[] args) throws Exception {
URI uri = new URI("xcc://demo:password@localhost:9470/Arg");
query = "for $x in cts:search(//PLAY,cts:element-word-query(xs:QName(\"LINE\"),\"King\")) return ($x//TITLE)";
ContentSource con =
ContentSourceFactory.newContentSource(
"localhost", 9470,
"demo", "password",
"Arg", newTrustOptions());
Session see = con.newSession();
Request req = see.newAdhocQuery(query);
ResultSequence rs = see.submitRequest (req);
System.out.println (rs.asString());
see.close();
}
protected static SecurityOptions newTrustOptions() throws Exception {
TrustManager[] trust =
new TrustManager[] {
new X509TrustManager() {
public void checkClientTrusted(
X509Certificate[] x509Certificates,
String s) throws CertificateException {
}
public void checkServerTrusted(
X509Certificate[] x509Certificates,
String s) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
};
SSLContext sslContext = SSLContext.getInstance("SSLv3");
sslContext.init(null, trust, null);
return new SecurityOptions(sslContext);
}
}
在连接URL中,使用
xcc
而不是xcc
您还可以查看一个同时处理
xcc
和xcc
的示例。您是否使用了正确的端口号?