我使用 Solr 作为搜索服务器并将我的所有数据保存在 Solr 中。我正在使用 Solr 版本 5.5.2。Solr 以 SSL 模式运行,使用主机名为 localhost 的自签名证书。我无法在此处添加主机名,因为在生成证书时我没有要安装它的机器名称。
我正在从 wildfly 10 连接到这个 solr 服务器。在 wildfly 10 上,我已将我的 solr 证书添加为受信任的,因此它不会抱怨自签名证书,但由于我的 wildfly 在不同的主机上,我在 URL 中使用主机名调用 solr,而 wildfly 是提高低于错误。
Caused by: org.apache.solr.client.solrj.SolrServerException: IOException occured when talking to server at: https://SOLR_HOST:8983/solr/default_core
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:589)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:240)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:229)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:149)
at org.apache.solr.client.solrj.SolrClient.query(SolrClient.java:974)
at org.apache.solr.client.solrj.SolrClient.query(SolrClient.java:990)
at org.springframework.data.solr.core.SolrTemplate$11.doInSolr(SolrTemplate.java:512)
at org.springframework.data.solr.core.SolrTemplate$11.doInSolr(SolrTemplate.java:509)
at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:168)
... 66 more
Caused by: javax.net.ssl.SSLException: Certificate for <SOLR_HOST> doesn't match common name of the certificate subject: localhost
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:173)
at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:61)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:141)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:114)
at org.apache.http.conn.ssl.SSLSocketFactory.verifyHostname(SSLSocketFactory.java:580)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:554)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:412)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:179)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:328)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:612)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:447)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:884)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:481)
... 74 more
由于我没有将我的 solr 服务器暴露在我的网络之外,我只想忽略此错误并禁用主机名验证。此处的 HttpClient 由 Solrj 创建并在 SolrTemplate 中管理,因此我们无法控制此处建议的添加自定义策略
基本上我想为我的设置禁用主机名验证。对此的任何建议将不胜感激。