我想在此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 address = localhost / 127.0.0.1:9470,pool = 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);
}
}
答案 0 :(得分:1)
在连接网址中,使用xccs
代替xcc
。
您还可以查看https://github.com/marklogic/xqsync/blob/1cf82faa2fa2e7fb3fa06f41e0938bf5b002b7fa/src/java/com/marklogic/ps/Connection.java#L100,查看同时处理xcc
和xccs
的示例。