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

Java調(diào)用Azure證書錯誤javax.net.ssl.SSLHandshakeException

這篇具有很好參考價值的文章主要介紹了Java調(diào)用Azure證書錯誤javax.net.ssl.SSLHandshakeException。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

一、背景

Azure作為微軟的公有云平臺,提供了非常豐富的SDK和API讓開發(fā)人員可以非常方便的調(diào)用的各項服務(wù)。公司業(yè)務(wù)需要,我們需要訪問Azure上注冊的應(yīng)用程序,需要訪問https地址

https://login.microsoftonline.com/?your-??tenant-id 。

二、錯誤信息

簡短報錯信息:javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.ssl.Alert.createSSLException(Alert.java:131) ~[na:1.8.0_332]
        at sun.security.ssl.TransportContext.fatal(TransportContext.java:324) ~[na:1.8.0_332]
        at sun.security.ssl.TransportContext.fatal(TransportContext.java:267) ~[na:1.8.0_332]
        at sun.security.ssl.TransportContext.fatal(TransportContext.java:262) ~[na:1.8.0_332]
        at sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:654) ~[na:1.8.0_332]
        at sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:473) ~[na:1.8.0_332]
        at sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:369) ~[na:1.8.0_332]
        at sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:377) ~[na:1.8.0_332]
        at sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:444) ~[na:1.8.0_332]
        at sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:422) ~[na:1.8.0_332]
        at sun.security.ssl.TransportContext.dispatch(TransportContext.java:182) ~[na:1.8.0_332]
        at sun.security.ssl.SSLTransport.decode(SSLTransport.java:152) ~[na:1.8.0_332]
        at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1397) ~[na:1.8.0_332]
        at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1305) ~[na:1.8.0_332]
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:440) ~[na:1.8.0_332]
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) ~[na:1.8.0_332]
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:197) ~[na:1.8.0_332]
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1572) ~[na:1.8.0_332]
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1500) ~[na:1.8.0_332]
        at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480) ~[na:1.8.0_332]
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:352) ~[na:1.8.0_332]
        at com.microsoft.aad.msal4j.DefaultHttpClient.readResponseFromConnection(DefaultHttpClient.java:105) ~[msal4j-1.13.0.jar!/:1.13.0]
        at com.microsoft.aad.msal4j.DefaultHttpClient.executeHttpGet(DefaultHttpClient.java:47) ~[msal4j-1.13.0.jar!/:1.13.0]
        at com.microsoft.aad.msal4j.DefaultHttpClient.send(DefaultHttpClient.java:35) ~[msal4j-1.13.0.jar!/:1.13.0]
        at com.microsoft.aad.msal4j.HttpHelper.executeHttpRequestWithRetries(HttpHelper.java:96) ~[msal4j-1.13.0.jar!/:1.13.0]
        at com.microsoft.aad.msal4j.HttpHelper.executeHttpRequest(HttpHelper.java:49) ~[msal4j-1.13.0.jar!/:1.13.0]
        ... 16 common frames omitted
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:456) ~[na:1.8.0_332]
        at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:323) ~[na:1.8.0_332]
        at sun.security.validator.Validator.validate(Validator.java:271) ~[na:1.8.0_332]
        at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:315) ~[na:1.8.0_332]
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:223) ~[na:1.8.0_332]
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:129) ~[na:1.8.0_332]
        at sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:638) ~[na:1.8.0_332]
        ... 37 common frames omitted
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141) ~[na:1.8.0_332]
        at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126) ~[na:1.8.0_332]
        at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280) ~[na:1.8.0_332]
        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:451) ~[na:1.8.0_332]
        ... 43 common frames omitted

2022-08-16 17:26:53.542 ERROR 3480 --- [   scheduling-1] c.xx.xx.service.impl.XXServiceImpl  : get new EWS Token With Certificate error : java.util.concurrent.ExecutionException: com.microsoft.aad.msal4j.MsalClientException: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

三、問題原因和解決思路

Java的keystore當(dāng)中沒有該網(wǎng)站https證書。需要手動使用keytool命令導(dǎo)入到j(luò)re里面。當(dāng)然我們也可以使用Java的TrustManager忽略所有的SSL請求的證書(不推薦用于生產(chǎn)環(huán)境)。本次我們是直接導(dǎo)入對應(yīng)的證書到j(luò)re里面來解決問題。

四、獲取網(wǎng)站的證書

1.谷歌瀏覽器直接訪問 https://login.microsoftonline.com/

快捷鍵F12進(jìn)入開發(fā)者模式。進(jìn)入security安全菜單下,可以看到顯示“This page is secure (valid HTTPS)”,點擊“view certificate ”

Java調(diào)用Azure證書錯誤javax.net.ssl.SSLHandshakeException

?在證書界面,我們可以將證書復(fù)制到以便查看。

Java調(diào)用Azure證書錯誤javax.net.ssl.SSLHandshakeException

直接下一步,導(dǎo)出格式選擇base64編碼。

Java調(diào)用Azure證書錯誤javax.net.ssl.SSLHandshakeException

?設(shè)置證書路徑和文件名,點擊完成即可。最終格式的.cer文件。

五、導(dǎo)入證書

將證書放在某個位置,建議放在C盤cert文件。

管理員運行控制臺

先進(jìn)入到Java的bin文件夾,我這里是

cd C:\Program Files\Java\jdk1.8.0_192\bin

?執(zhí)行下面的命令導(dǎo)入指定證書(需要根據(jù)自己的實際修改)

keytool -import -alias login.microsoftonline.com -keystore "C:\Program Files\Java\jre1.8.0_192\lib\security\cacerts" -file c:\cert\login.microsoftonline.com.cer

-alias 后面是別名

-keystore 后面是keystore路徑

-file 后面是剛剛導(dǎo)出的證書文件路徑

安裝證書與查看證書默認(rèn)密碼是changeit

六、查看證書

# 查看所有證書

keytool -list -keystore "C:\Program Files\Java\jre1.8.0_192\lib\security\cacerts"

# 查看指定名字的證書文章來源地址http://www.zghlxwxcb.cn/news/detail-457036.html

keytool -list -v -alias login.microsoftonline.com -keystore "C:\Program Files\Java\jre1.8.0_192\lib\security\cacerts" -storepass changeit

到了這里,關(guān)于Java調(diào)用Azure證書錯誤javax.net.ssl.SSLHandshakeException的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

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

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

相關(guān)文章

  • Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateNotYetValidException:

    Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateNotYetValidException:

    生命就像人家的魔法書,涂涂改改又是一年?? 原因 解決辦法 完整報錯: 在執(zhí)行sqoop腳本導(dǎo)數(shù)據(jù)的時候出現(xiàn) Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateNotYetValidException: NotBefore: Tue Oct 11 17:24:18 CST 2022 報錯,證書不合法,解決辦法是jdbc連接MySQL時不使用ssl協(xié)議,

    2024年02月15日
    瀏覽(58)
  • javax.net.ssl.SSLHandshakeException

    解決辦法升級jdk版本或者修改jdk文件 1、對于服務(wù)器來說要支持域名并且不進(jìn)行ssl證書校驗,需要升級到j(luò)dk1.8的201版本及以上 2、修改…JavaJDKjrelibsecurity目錄下java.security文件,添加下面語句到文件內(nèi)容中

    2024年02月11日
    瀏覽(21)
  • Macos jdk ssl javax.net.ssl.SSLHandshakeException完美解決

    Macos jdk ssl javax.net.ssl.SSLHandshakeException完美解決

    報了這么一個錯誤 javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake 網(wǎng)上一大把,測試不能用,谷歌了一下,發(fā)現(xiàn)少配置了一個環(huán)境變量。 System.setProperty(\\\"jdk.tls.useExtendedMasterSecret\\\", \\\"false\\\");//設(shè)置環(huán)境變量 /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/security/java.se

    2024年02月13日
    瀏覽(25)
  • java項目實現(xiàn)讀寫分離,項目連接Linux部署的數(shù)據(jù)庫異常javax.net.ssl.SSLHandshakeException: No appropriate protocol

    java項目實現(xiàn)讀寫分離,項目連接Linux部署的數(shù)據(jù)庫異常javax.net.ssl.SSLHandshakeException: No appropriate protocol

    1、對項目進(jìn)行優(yōu)化實現(xiàn)讀寫分離,項目啟動時報錯如下: Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) 原因:javax.net.ssl.SSLHandshakeException:沒有適當(dāng)?shù)膮f(xié)議(協(xié)議被禁用或密碼套件不合適) 2、bug解決: ? ? 注意: useSSL=f

    2024年02月04日
    瀏覽(23)
  • javax.net.ssl.SSLHandshakeException: No appropriate protocol

    javax.net.ssl.SSLHandshakeException: No appropriate protocol

    報錯: 解釋代碼 這是一個Spring Boot應(yīng)用程序的配置文件中的一行代碼,用于設(shè)置數(shù)據(jù)庫連接信息。具體解釋如下: spring.datasource.url :這是Spring Boot中用于配置數(shù)據(jù)源URL的屬性。 jdbc:mysql://ip:3306/dbuser :這是JDBC URL,用于指定數(shù)據(jù)庫的類型(MySQL)、主機地址(ip)、端口號(

    2024年02月20日
    瀏覽(22)
  • javax.net.ssl.SSLHandshakeException: PKIX path building failed

    javax.net.ssl.SSLHandshakeException: PKIX path building failed

    錯誤信息 本地環(huán)境缺少ssl證書 一、下載證書 ???????? 可以通過瀏覽器下載;也可以使用命令行 1、瀏覽器 查看證書,直接導(dǎo)出即可 2、命令行 openssl s_client -connect 目標(biāo)網(wǎng)址:端口號 /dev/null | sed -ne \\\'/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p\\\' 證書名.crt 二、導(dǎo)入證書 1. 將證書移動到

    2023年04月22日
    瀏覽(24)
  • 解決javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException

    Java Spring應(yīng)用發(fā)送數(shù)據(jù)報如下問題。 用httpclient訪問https資源時,會出現(xiàn)異常,與環(huán)境也有關(guān)系,有些機器請求正常。 1.復(fù)制 附錄 代碼到文本文件中,改名為InstallCert.java。然后在命令行中執(zhí)行命令,編譯InstallCert.java: ?2.再執(zhí)行以下命令: 說明:網(wǎng)址處不需要輸入(https://)信

    2024年02月16日
    瀏覽(23)
  • 解決報錯:javax.net.ssl.SSLHandshakeException: No appropriate protocol

    解決報錯:javax.net.ssl.SSLHandshakeException: No appropriate protocol

    使用對象存儲進(jìn)行文件上傳時報錯 注:該問題只要需要用到http的都有可能出現(xiàn),不是只針對對象存儲 jdk 的 java.security 文件存在配置問題 1、查看當(dāng)前服務(wù)器使用的 jdk 版本 命令: java -version 2、查看該jdk的安裝目錄 命令: find / -name java.security 這里選擇通過搜索 java.security 來

    2024年01月24日
    瀏覽(22)
  • javax.net.ssl.SSLHandshakeException:(HTTPS繞過安全認(rèn)證進(jìn)行請求鏈接)

    1、問題: 在使用jsoup爬取數(shù)據(jù)時,碰到了使用https的網(wǎng)站,遇到報錯:javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed 2、解決 后自己在網(wǎng)上查了一些資料,找到相關(guān)解決代碼: 3、方法調(diào)用 ?

    2024年02月08日
    瀏覽(32)
  • 【請求報錯:javax.net.ssl.SSLHandshakeException: No appropriate protocol】

    【請求報錯:javax.net.ssl.SSLHandshakeException: No appropriate protocol】

    在請求服務(wù)時報錯說SSL握手異常協(xié)議禁用啥的,而且我的連接數(shù)據(jù)庫的url也加了useSSL=false 在網(wǎng)上查找了方法原因后得知是jdk的問題 修改 java.security? 文件 Linux 默認(rèn)路徑 /usr/lib/jvm/jdk/jre/lib/security Windows默認(rèn)路徑 C:Program FilesJavajdkjrelibsecurity vi 進(jìn)去刪除jdk.tls.disabledAlgorithms

    2024年02月10日
    瀏覽(25)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包