I am using the XMPP component of apache camel to send messages using the Openfire server. However, when the identity store certificate is generated the call of the service returns an error, and when I delete this certificate from open fire, the service works perfectly: Below is a screenshot of the certificate stores in Openfire:
package com.example.ChatServiceProject;
import java.io.InputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.model.dataformat.JsonLibrary;
import org.apache.camel.model.rest.RestBindingMode;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import com.google.gson.Gson;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.igniterealtime.restclient.RestClient.RestClientBuilder;
import org.igniterealtime.restclient.entity.AuthenticationToken;
import org.igniterealtime.restclient.entity.UserEntities;
@Component
public class XMPPChatService extends RouteBuilder{
@Override
public void configure() throws Exception {
restConfiguration()
.bindingMode(RestBindingMode.auto);
rest("/xmppchat/{sender}/{pass}/{reciever}/{message}/{room}")
.get()
.to("direct:jennychat");
from("direct:jennychat")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
String header = exchange.getIn().getHeaders().get("CamelHttpPath").toString();
System.out.println(header.split("/")[5]);
exchange.getIn().setBody(header.split("/")[5]);
}
})
.toD("xmpp://${header.sender}:5222?participant=${header.reciever}&password=${header.pass}&room=${header.room}");
rest("/getRoomChat/{roomName}")
.get()
.to("direct:getroom");
from("direct:getroom")
.process(new GetRoomChatProcessor())
.unmarshal().json(JsonLibrary.Gson)
.log("${body}");
rest("/chat/{sender}/{pass}/{reciever}/{message}/{room}")
.get()
.to("direct:chat");
from("direct:chat")
.process(new XMPPChatProcessor())
.log("${body}");
}
}
}
and this is the error in eclipse:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target,
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
SO any idea how to make the service run with the certificate enable, because I need the certificate for creating users, Thank you!!
Yes, I did face this issue many times. Here is the fix (kindly, follow the below steps).
Step 1. You need to export certificate from browser as DER (*.cer). Step 2. You need to import *.cer files into the cacerts using java keytool command.
For more details along with screens shots pleasse go through the following link.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.