简体   繁体   English

使用 xmpp 时出现错误“sun.security.provider.certpath.SunCertPathBuilderException:无法找到到所请求目标的有效证书路径”

[英]Error ' sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target' when using xmpp

I am using the XMPP component of apache camel to send messages using the Openfire server.我正在使用 apache camel 的 XMPP 组件使用 Openfire 服务器发送消息。 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:但是,当生成身份存储证书时,服务的调用返回错误,当我从 open fire 中删除此证书时,该服务完美运行: 下面是 Openfire 中证书存储的屏幕截图: 在此处输入图像描述

code:代码:

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:这是 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).步骤 1.您需要从浏览器导出证书为 DER (*.cer)。 Step 2. You need to import *.cer files into the cacerts using java keytool command.步骤 2.您需要使用 java keytool 命令将 *.cer 文件导入 cacerts。

For more details along with screens shots pleasse go through the following link.有关更多详细信息以及屏幕截图,请通过以下链接访问 go。

https://thebasictechinfo.com/java-8/pkixunable-to-find-valid-certification-path-to-requested-target-fix/ https://thebasictechinfo.com/java-8/pkixunable-to-find-valid-certification-path-to-requested-target-fix/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求的目标错误的有效证书路径 - sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target error 错误:无法找到请求目标的有效证书路径 (sun.security.provider.certpath.SunCertPathBuilderException) - Error : unable to find valid certification path to requested target (sun.security.provider.certpath.SunCertPathBuilderException) GCP-PUBSUB:-sun.security.provider.certpath.SunCertPathBuilderException: 无法找到请求目标的有效认证路径 - GCP-PUBSUB:-sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 引起:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径 - Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target PKIX 构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径 - PKIX building failed:sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Java:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效认证路径 - Java: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到到请求目标的有效认证路径? - PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target? CXF:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径 - CXF:PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到到请求目标的有效认证路径 - PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 无法找到到请求的目标PKIX路径构建的有效证书路径失败:sun.security.provider.certpath.SunCertPathBuilderException - unable to find valid certification path to requested target PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM