2015-04-06 87 views
3

我的应用程序抛出这个错误:GAE网址提取服务为HTTPS

[INFO] Caused by: java.lang.ClassCastException: com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection cannot be cast to javax.net.ssl.HttpsURLConnection 
[INFO] at info.modprobe.browserid.Verifier.verify(Verifier.java:76) 

而导致错误的代码是:

 URL verifierURL = new URL(this.url); 
     String response = ""; 
     HttpsURLConnection connection = (HttpsURLConnection) verifierURL 
       .openConnection(); // error here... 
     connection.setRequestMethod("POST"); 
     connection.setRequestProperty("Content-Type", 
       "application/json; charset=utf-8"); 
     connection.setDoOutput(true); 

当尝试使用此library做Mozilla的个人验证。我想知道自从GAE网址提取服务支持HTTPS后会出现什么问题。

+0

闻起来像一个导入问题,你可以请提供该类的导入块? – jirungaray 2015-04-06 22:18:26

回答

3

尝试

HttpURLConnection connection = (HttpURLConnection) verifierURL.openConnection(); 

,而不是

HttpsURLConnection connection = (HttpsURLConnection) verifierURL.openConnection(); 

它将创建它所需要的下方,也为HTTPS,但不要强迫剧组到HTTPS,因为它使用了类(URLFetchServiceStreamHandler $连接)taht扩展HttpURLConnection但不HttpsURLConnection