国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

報(bào)錯 unable to find valid certification path to requested target executing

這篇具有很好參考價(jià)值的文章主要介紹了報(bào)錯 unable to find valid certification path to requested target executing。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

提示信息:

審核失敗!sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target executing POST 。。。 。。。

出現(xiàn)原因
這個(gè)問題的根本原因是你安裝JDK時(shí),Java\jar 1.8.0_141\lib\ext\里面缺少了一個(gè)安全憑證jssecacerts證書文件,通過運(yùn)行下面類可以生成證書,將生成的證書放在Java\jar 1.8.0_141\lib\ext\這個(gè)目錄下,重啟編譯器就可以解決。

解決方式有兩種 第一種直接在發(fā)送請求的時(shí)候忽略掉http證書驗(yàn)證,第二種方式本地下載個(gè)證書

第一種:解決方式是在發(fā)送http請求的時(shí)候,可以過濾掉所有的https證書驗(yàn)證。

/**
 * POST請求
 *
 * @param url
 * @param data
 * @return
 */
public String sendPost() {
    LOG.info("send to tanggong : " + data);
    String result = null;
    CloseableHttpClient httpClient = HttpClients.createDefault();
    //isNoSSL是否需要走特殊方法
    if(isNoSSL) 
    { 
        httpClient = (CloseableHttpClient)wrapClient(httpClient); 
    }
    HttpPost post = new HttpPost(httpUrl);
    post.addHeader("Content-type","application/json; charset=utf-8");
    post.setHeader("Accept", "application/json");
    CloseableHttpResponse response = null;
    try {
        StringEntity sen = new StringEntity(data.toString(),Charset.forName("UTF-8"));
        sen.setContentEncoding("UTF-8");
        sen.setContentType("application/json");
        post.setEntity(sen);
        response = httpClient.execute(post);
        if (response != null && response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            result = EntityUtils.toString(entity);
        }
        LOG.info("ZP return :" + result);
        return result;
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            httpClient.close();
            if (response != null) {
                response.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return null;
}
 
 
/**
 * 避免HttpClient的”SSLPeerUnverifiedException: peer not authenticated”異常
 * 不用導(dǎo)入SSL證書
 * @param base
 * @return
 */ 
public static HttpClient wrapClient(HttpClient base) { 
    try { 
        SSLContext ctx = SSLContext.getInstance("TLS"); 
        X509TrustManager tm = new X509TrustManager() { 
        
            @Override
            public void checkClientTrusted(java.security.cert.X509Certificate[] arg0, String arg1)
                    throws java.security.cert.CertificateException {
                // TODO Auto-generated method stub
                 
            }
 
            @Override
            public void checkServerTrusted(java.security.cert.X509Certificate[] arg0, String arg1)
                    throws java.security.cert.CertificateException {
                // TODO Auto-generated method stub
                 
            }
 
            @Override
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                // TODO Auto-generated method stub
                return null;
            } 
        }; 
        ctx.init(null, new TrustManager[] { tm }, null); 
        SSLConnectionSocketFactory ssf = new SSLConnectionSocketFactory(ctx,NoopHostnameVerifier.INSTANCE); 
        CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(ssf).build(); 
        return httpclient; 
    } catch (Exception ex) { 
        ex.printStackTrace(); 
        return HttpClients.createDefault(); 
    } 
} 

第二種方式:

1、生成安全證書
2、放入jre相應(yīng)路徑下

生成安全證書

import java.io.*;
import java.net.URL;
 
import java.security.*;
import java.security.cert.*;
 
import javax.net.ssl.*;
 
public class InstallCert {
 
    public static void main(String[] args) throws Exception {
        String host;
        int port;
        char[] passphrase;
        if ((args.length == 1) || (args.length == 2)) {
            String[] c = args[0].split(":");
            host = c[0];
            port = (c.length == 1) ? 443 : Integer.parseInt(c[1]);
            String p = (args.length == 1) ? "changeit" : args[1];
            passphrase = p.toCharArray();
        } else {
            System.out.println("Usage: java InstallCert <host>[:port] [passphrase]");
            return;
        }
 
        File file = new File("jssecacerts");
        if (file.isFile() == false) {
            char SEP = File.separatorChar;
            File dir = new File(System.getProperty("java.home") + SEP
                    + "lib" + SEP + "security");
            file = new File(dir, "jssecacerts");
            if (file.isFile() == false) {
                file = new File(dir, "cacerts");
            }
        }
        System.out.println("Loading KeyStore " + file + "...");
        InputStream in = new FileInputStream(file);
        KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
        ks.load(in, passphrase);
        in.close();
 
        SSLContext context = SSLContext.getInstance("TLS");
        TrustManagerFactory tmf =
                TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        tmf.init(ks);
        X509TrustManager defaultTrustManager = (X509TrustManager)tmf.getTrustManagers()[0];
        SavingTrustManager tm = new SavingTrustManager(defaultTrustManager);
        context.init(null, new TrustManager[] {tm}, null);
        SSLSocketFactory factory = context.getSocketFactory();
 
        System.out.println("Opening connection to " + host + ":" + port + "...");
        SSLSocket socket = (SSLSocket)factory.createSocket(host, port);
        socket.setSoTimeout(10000);
        try {
            System.out.println("Starting SSL handshake...");
            socket.startHandshake();
            socket.close();
            System.out.println();
            System.out.println("No errors, certificate is already trusted");
        } catch (SSLException e) {
            System.out.println();
            e.printStackTrace(System.out);
        }
 
        X509Certificate[] chain = tm.chain;
        if (chain == null) {
            System.out.println("Could not obtain server certificate chain");
            return;
        }
 
        BufferedReader reader =
                new BufferedReader(new InputStreamReader(System.in));
 
        System.out.println();
        System.out.println("Server sent " + chain.length + " certificate(s):");
        System.out.println();
        MessageDigest sha1 = MessageDigest.getInstance("SHA1");
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        for (int i = 0; i < chain.length; i++) {
            X509Certificate cert = chain[i];
            System.out.println
                    (" " + (i + 1) + " Subject " + cert.getSubjectDN());
            System.out.println("   Issuer  " + cert.getIssuerDN());
            sha1.update(cert.getEncoded());
            System.out.println("   sha1    " + toHexString(sha1.digest()));
            md5.update(cert.getEncoded());
            System.out.println("   md5     " + toHexString(md5.digest()));
            System.out.println();
        }
 
        System.out.println("Enter certificate to add to trusted keystore or 'q' to quit: [1]");
        String line = reader.readLine().trim();
        int k;
        try {
            k = (line.length() == 0) ? 0 : Integer.parseInt(line) - 1;
        } catch (NumberFormatException e) {
            System.out.println("KeyStore not changed");
            return;
        }
 
        X509Certificate cert = chain[k];
        String alias = host + "-" + (k + 1);
        ks.setCertificateEntry(alias, cert);
 
        OutputStream out = new FileOutputStream("jssecacerts");
        ks.store(out, passphrase);
        out.close();
 
        System.out.println();
        System.out.println(cert);
        System.out.println();
        System.out.println
                ("Added certificate to keystore 'jssecacerts' using alias '"
                        + alias + "'");
    }
 
    private static final char[] HEXDIGITS = "0123456789abcdef".toCharArray();
 
    private static String toHexString(byte[] bytes) {
        StringBuilder sb = new StringBuilder(bytes.length * 3);
        for (int b : bytes) {
            b &= 0xff;
            sb.append(HEXDIGITS[b >> 4]);
            sb.append(HEXDIGITS[b & 15]);
            sb.append(' ');
        }
        return sb.toString();
    }
 
    private static class SavingTrustManager implements X509TrustManager {
 
        private final X509TrustManager tm;
        private X509Certificate[] chain;
 
        SavingTrustManager(X509TrustManager tm) {
            this.tm = tm;
        }
 
        public X509Certificate[] getAcceptedIssuers() {
            throw new UnsupportedOperationException();
        }
 
        public void checkClientTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {
            throw new UnsupportedOperationException();
        }
 
        public void checkServerTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {
            this.chain = chain;
            tm.checkServerTrusted(chain, authType);
        }
    }
 
}

D:\桌面\ 。。。\src\main\java\com\ideal\sk>java InstallCert 需要訪問的地址:端口

或者設(shè)置idea 運(yùn)行的args參數(shù)

執(zhí)行完后會出現(xiàn)這樣的界面

直接輸入1,然后會在相應(yīng)的目錄下產(chǎn)生一個(gè)名為‘jssecacerts’的證書

將證書copy到$JAVA_HOME/jre/lib/security目錄下

重啟程序即可解決文章來源地址http://www.zghlxwxcb.cn/news/detail-776312.html

到了這里,關(guān)于報(bào)錯 unable to find valid certification path to requested target executing的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • sqlmap報(bào)錯[CRITICAL] unable to connect to the target URL. sqlmap is going to retry the request(s)

    sqlmap報(bào)錯[CRITICAL] unable to connect to the target URL. sqlmap is going to retry the request(s)

    如圖,用讀文件的方式跑sqlmap時(shí),明明站點(diǎn)是通的,卻提示不可達(dá),后來發(fā)現(xiàn)目標(biāo)站點(diǎn)是HTTPS的,sqlmap默認(rèn)是用http協(xié)議 解決方案: 添加代理,讓sqlmap走burp的代理,添加ssl 具體命令: 問題解決。

    2024年02月12日
    瀏覽(22)
  • RuntimeError: Unable to find a valid cuDNN algorithm to run convolution

    RuntimeError: Unable to find a valid cuDNN algorithm to run convolution

    使用yolov5l模型訓(xùn)練時(shí)出現(xiàn)報(bào)錯,但是昨天使用yolov5s模型時(shí)是可以正常訓(xùn)練的。 發(fā)生報(bào)錯的原因是gpu內(nèi)存占用過高,terminal輸入nvidia-smi查看gpu的使用情況。 ? 我們需要把bach_size調(diào)小,一般建議是8的倍數(shù),內(nèi)存不夠用時(shí)盡量調(diào)低,此處我設(shè)置成了16。 結(jié)果運(yùn)行正常。 使用yol

    2024年02月11日
    瀏覽(97)
  • Unable to connect to the server: x509: certificate has expired or is not yet valid

    手動更新所有證書,執(zhí)行命令 更新用戶配置 用更新后的admin.conf替換/root/.kube/config文件 k8s解決證書過期官方文檔:https://kubernetes.io/zh-cn/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/ 幫助文檔: https://www.cnblogs.com/00986014w/p/13095628.html

    2024年02月04日
    瀏覽(100)
  • 【bug解決】RuntimeError: Unable to find a valid cuDNN algorithm to run convolution

    進(jìn)行深度學(xué)習(xí)的算法模型訓(xùn)練的時(shí)候,終端報(bào)錯: 產(chǎn)生報(bào)錯的原因可能有兩種: 1.模型訓(xùn)練的環(huán)境中cudnn,CUDA的版本號不匹配 解決辦法:安裝對應(yīng)的cudnn,以及cuda,找到對應(yīng)的torch框架,進(jìn)行安裝 2.其實(shí)問題更加簡單,是模型的訓(xùn)練的batch-size訓(xùn)練過大了,調(diào)整更小,就可以了

    2024年02月11日
    瀏覽(90)
  • K8S異常之Unable to connect to the server: x509: certificate has expired or is not yet valid

    K8S異常之Unable to connect to the server: x509: certificate has expired or is not yet valid

    2.1 處理步驟 2.2 處理步驟詳細(xì)情況 如上,發(fā)現(xiàn)很多證書都是 invalid 的狀態(tài),接著更新證書: 如下,更新證書后,證書過期時(shí)間已經(jīng)更新為 365d 3.1 再次查看kubectl get node,發(fā)現(xiàn)有新的錯誤: error: You must be logged in to the server (Unauthorized) 3.2 上述錯誤解決方案 備份配置文件 cp -rp

    2024年02月03日
    瀏覽(99)
  • Git Clone 報(bào)錯 `SSL certificate problem: unable to get local issuer certificate`

    Git Clone 報(bào)錯 `SSL certificate problem: unable to get local issuer certificate`

    如果您在嘗試克隆Git存儲庫時(shí)得到 “SSL certificate problem: unable to get local issuer certificate” 的錯誤,這意味著Git無法驗(yàn)證遠(yuǎn)程存儲庫的SSL證書。如果SSL證書是自簽名的,或者SSL證書鏈有問題,就會發(fā)生這種情況。 想要修復(fù)這個(gè)錯誤,可以嘗試以下解決方案: 一、 禁用SSL驗(yàn)證: 一般

    2024年02月07日
    瀏覽(113)
  • 關(guān)于picgo圖床報(bào)錯“unable to verify the first certificate“

    關(guān)于picgo圖床報(bào)錯“unable to verify the first certificate“

    關(guān)于picgo圖床報(bào)錯\\\"unable to verify the first certificate\\\" 編程上的疑難雜癥(一) 問題:本人picgo加github圖床上傳出現(xiàn)以下問題 \\\"message\\\": \\\"unable to verify the first certificate\\\"(無法驗(yàn)證第一證書) 問題分析: 圖床是github圖床,工具是picgo,為了可以順利訪問github用到steam++(Watt Toolkit)加速

    2024年02月11日
    瀏覽(191)
  • Composer出現(xiàn) SSL certificate problem: unable to get local issuer certificate 報(bào)錯的解決方法

    Composer出現(xiàn) SSL certificate problem: unable to get local issuer certificate 報(bào)錯的解決方法

    Composer出現(xiàn)crul SSL報(bào)錯的問題是沒有安裝CA證書導(dǎo)致的?。?! 錯誤信息如下: [ComposerDownloaderTransportException] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ? curl error 60 while downloading https://repo.packagist.org/package

    2024年02月03日
    瀏覽(122)
  • 使用postman時(shí),報(bào)錯SSL Error: Unable to verify the first certificate

    使用postman時(shí),報(bào)錯SSL Error: Unable to verify the first certificate

    開發(fā)中使用postman調(diào)用接口,出現(xiàn)以下問題,在確認(rèn)路徑、參數(shù)、請求方式均為正確的情況下 解決方法 File - Settings - SSL certification verification 關(guān)閉 找到圖中配置,這里默認(rèn)是打開狀態(tài),把它關(guān)閉即可:ON - OFF 再次請求接口 原因:使用 Postman 發(fā)起 HTTPS 請求時(shí),它會驗(yàn)證服務(wù)器的

    2024年02月04日
    瀏覽(35)
  • .net core中Grpc使用報(bào)錯:The remote certificate is invalid according to the validation procedure.

    因?yàn)镚rpc采用HTTP/2作為通信協(xié)議,默認(rèn)采用LTS/SSL加密方式傳輸,比如使用.net core啟動一個(gè) 服務(wù)端(被調(diào)用方) 時(shí): ? 其中使用UseHttps方法添加證書和秘鑰。 但是,有時(shí)候,比如開發(fā)階段,我們可能沒有證書,或者是一個(gè)自己制作的臨時(shí)測試證書,那么在 客戶端(調(diào)用方)

    2023年04月13日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包