【发布时间】:2016-05-26 13:08:06
【问题描述】:
我的代码:
URL url=new URL(https url with client id and clientsecret);
HttpURLConnection connect=(HttpURLConnection) url.openConnection();
connect.setRequestMethod("POST");
connect.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
connect.setDoOutput(true);
通过这个我得到了
javax.net.ssl.SSLHandshakeException:无法验证 SSL 证书 对于网址:(我的网址)
如果尝试更改为HttpsURLConnection:
URL url=new URL(https url with client id and clientsecret);
HttpsURLConnection connect=(HttpsURLConnection) url.openConnection();
connect.setRequestMethod("POST");
connect.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
connect.setDoOutput(true);
我来了
java.lang.ClassCastException: com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection 无法转换为 javax.net.ssl.HttpsURLConnection
我正在与 GAE 合作。我需要解决这个问题才能获得访问令牌。 通过查看较早的问题,我没有得到正确的解决方案。
当我通过“curl”尝试通过终端时,我能够获得有效的访问令牌。
curl --data "parameters like client id and client secret and the auth_code" my https url
在此之后我能够获得令牌的有效响应
【问题讨论】:
-
即使我尝试了在stackoverflow.com/questions/2893819/…找到的一些代码
-
这种情况是仅发生在开发服务器上还是在部署的应用程序上也发生?
-
我尚未在部署的应用程序中添加此代码。我只是在本地检查。
标签: java google-app-engine sslhandshakeexception