日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

钉钉提示请勿通过开发者调试模式_钉钉开放平台demo调试异常问题解决:hostname in certificate didn't match...

發(fā)布時(shí)間:2024/4/19 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 钉钉提示请勿通过开发者调试模式_钉钉开放平台demo调试异常问题解决:hostname in certificate didn't match... 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

今天研究釘釘?shù)拈_放平臺(tái),結(jié)果一個(gè)demo整了半天,這幫助系統(tǒng)寫的也很難懂。遇到兩個(gè)問題:

1、首先是執(zhí)行demo時(shí)報(bào)unable to find valid certification path to requested target,錯(cuò)誤信息如下:

request url=https://oapi.dingtalk.com/gettoken?corpid=...略...&corpsecret=...略..., exception, msg=sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

只不過經(jīng)研究,按網(wǎng)上的方式將證書導(dǎo)致到信任庫中也沒用,于是就找了段代碼直接跳過

2、但是報(bào)下面這個(gè)錯(cuò):

request url=https://oapi.dingtalk.com/get_jsapi_ticket?type=jsapi&access_token=2458f4d239173a12809cc94d1915d3b7,

exception, msg=hostname in certificate didn't match: != OR

具體沒空研究,找到下面代碼解決:

private staticCloseableHttpClient getHttpClient() {

RegistryBuilder registryBuilder = RegistryBuilder.create();

ConnectionSocketFactory plainSF= newPlainConnectionSocketFactory();

registryBuilder.register("http", plainSF);//指定信任密鑰存儲(chǔ)對(duì)象和連接套接字工廠

try{

KeyStore trustStore=KeyStore.getInstance(KeyStore.getDefaultType());//信任任何鏈接

TrustStrategy anyTrustStrategy = newTrustStrategy() {

@Overridepublic boolean isTrusted(X509Certificate[] x509Certificates, String s) throwsCertificateException {return true;

}

};

SSLContext sslContext=SSLContexts.custom().useTLS().loadTrustMaterial(trustStore, anyTrustStrategy).build();

LayeredConnectionSocketFactory sslSF= newSSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

registryBuilder.register("https", sslSF);

}catch(KeyStoreException e) {throw newRuntimeException(e);

}catch(KeyManagementException e) {throw newRuntimeException(e);

}catch(NoSuchAlgorithmException e) {throw newRuntimeException(e);

}

Registry registry =registryBuilder.build();//設(shè)置連接管理器

PoolingHttpClientConnectionManager connManager = newPoolingHttpClientConnectionManager(registry);//connManager.setDefaultConnectionConfig(connConfig);//connManager.setDefaultSocketConfig(socketConfig);//構(gòu)建客戶端

returnHttpClientBuilder.create().setConnectionManager(connManager).build();

}

參考:http://blog.csdn.net/shenyunsese/article/details/41075579

總結(jié)

以上是生活随笔為你收集整理的钉钉提示请勿通过开发者调试模式_钉钉开放平台demo调试异常问题解决:hostname in certificate didn't match...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。