linux下钉钉接口调用失败
Relinux下钉钉接口调用失败
问题解决了,在httpUrlConn中设置验证永远通过就可以了,至于为什么windows下可用,linux下必须加,这个问题有待研究
//验证hostname直接返回true
httpUrlConn.setHostnameVerifier(TrustAnyHostnameVerifier.getInstance());
验证类:
public class TrustAnyHostnameVerifier implements HostnameVerifier {
private static TrustAnyHostnameVerifier trustAnyHostnameVerifier;
public static TrustAnyHostnameVerifier getInstance() {
if (trustAnyHostnameVerifier == null) {
trustAnyHostnameVerifier = new TrustAnyHostnameVerifier();
}
return trustAnyHostnameVerifier;
}
public boolean verify(String hostname, SSLSession session) {
// 直接返回true
return true;
}
}
赞0
踩0