Here is my code if you want to give it a try :
public static void main(String[] args) throws Exception{
Settings settings = org.elasticsearch.common.settings.Settings.builder()
.put("cluster.name", "elastic_cluster6")
.put("xpack.security.user", "antoine:password")
.put("xpack.security.transport.ssl.enabled", "true")
.put("xpack.security.transport.ssl.keystore.path", "/Users/aparent/Downloads/es6.p12")
.put("xpack.security.transport.ssl.keystore.password", "password")
.put("xpack.security.transport.ssl.truststore.path", "/Users/aparent/Downloads/es6.p12")
.put("xpack.security.transport.ssl.truststore.password", "password")
.put("xpack.security.transport.ssl.verification_mode", "certificate")
.build();
TransportClient transportClient = new PreBuiltXPackTransportClient(settings);
transportClient.addTransportAddress(new TransportAddress(InetAddress.getByName("xx.xx.xx.xx"), 9302));
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
SearchModule searchModule = new SearchModule(settings, true, Collections.<SearchPlugin> emptyList());
try (XContentParser parser = XContentFactory.xContent(XContentType.JSON)
.createParser(new NamedXContentRegistry(searchModule.getNamedXContents()), DeprecationHandler.THROW_UNSUPPORTED_OPERATION, "{ \"query\": {\"match_all\": {} }}")) {
searchSourceBuilder.parseXContent(parser);
}
SearchRequestBuilder searchRequestBuilder = new SearchRequestBuilder(transportClient, SearchAction.INSTANCE)
.setTypes("tables")
.addSort(org.elasticsearch.search.sort.FieldSortBuilder.DOC_FIELD_NAME, org.elasticsearch.search.sort.SortOrder.ASC)
.setScroll(new org.elasticsearch.common.unit.TimeValue(1000))
.setSearchType(org.elasticsearch.action.search.SearchType.DEFAULT);
org.elasticsearch.action.search.SearchResponse searchResponse = searchRequestBuilder.setSource(searchSourceBuilder).execute().actionGet();
while (true) {
for (SearchHit searchHit : searchResponse.getHits().getHits()) {
System.out.println(searchHit.toString());
}
}
}
I keep getting the same error not an SSL/TLS record
.