[英]Volley library and HTTPS requests
I tried to look for some answers for me here, but I just fail to find anything that solves my problem. 我试着在这里寻找一些答案,但我找不到任何可以解决我问题的方法。
In project I am working on we are going to change our domain. 在我正在研究的项目中,我们将改变我们的域名。 Change is bit tricky - we have to also change connection from HTTP to HTTPS. 改变有点棘手 - 我们还必须改变从HTTP到HTTPS的连接。 I've received .crt key (let's say, example.tech.crt - will change all of company name to "example"). 我收到了.crt密钥(例如,example.tech.crt - 将所有公司名称更改为“example”)。 After few hours of constant failures I decided to write here. 经过几个小时的不断失败,我决定写在这里。
First of all, I tried using this tutorial http://ogrelab.ikratko.com/using-android-volley-with-self-signed-certificate/ - and it didn't work (I don't even mean that I had to use deprecated Apache libs because of API23). 首先,我尝试使用本教程http://ogrelab.ikratko.com/using-android-volley-with-self-signed-certificate/ - 它没有用(我甚至不是说我有因API23而使用已弃用的Apache库。 In case this is needed, this is how I created BKS file: 如果需要,这就是我创建BKS文件的方式:
keytool -importcert -v -trustcacerts -file "example.tech.crt" -alias example_tech
-keystore "example_tech.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider
-providerpath "bcprov-jdk16-146.jar" -storetype BKS
Then, I tried this approach Does Android Volley support SSL? 然后,我试过这种方法Android Volley是否支持SSL? - the one from best answer (with ignoring domain name check). - 最佳答案(忽略域名检查)。 I still tried to use BKS file - I've got some exceptions about casting errors, so I changed line: 我仍然试图使用BKS文件 - 我有一些关于转换错误的例外,所以我更改了行:
CertificateFactory cf = CertificateFactory.getInstance("X.509");
to 至
CertificateFactory cf = CertificateFactory.getInstance("X.509", "BC");
as suggested somewhere - error still persisted. 正如某处所建议的那样 - 错误仍然存在。 I tried to use .crt file instead of BKS - I still fail. 我试图使用.crt文件而不是BKS - 我仍然失败。
Every single time I get same error: 我每次都得到同样的错误:
javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException:
SSL handshake aborted: ssl=0x650f83a0: Failure in SSL library, usually a protocol error
error:14077102:SSL routines:SSL23_GET_SERVER_HELLO:unsupported protocol
(external/openssl/ssl/s23_clnt.c:714 0x5fda0d74:0x00000000)
I tried to do pretty much same requests using Postman and they work on same address without any problem, so this is not server problem. 我尝试使用Postman执行相同的请求,并且它们在相同的地址上工作没有任何问题,因此这不是服务器问题。 I tried to use various domains - example.tech, www.example.tech, example.tech:80 and so on (always with https of course). 我尝试使用各种域名 - example.tech,www.example.tech,example.tech:80等等(当然总是使用https)。
Below is example curl-like request (of course censored): 下面是示例卷曲式请求(当然是审查):
curl request: curl -X "POST"
-D "grant_type=password&password=[passwordHere]&username=[emailHere]&"
-H 'Authorization: Basic [tokenHere]
"https://example.tech/oauth/token"
I fail to see what's wrong with my code and I'd be really happy to see what I am doing wrong in here. 我没有看到我的代码有什么问题,我很高兴看到我在这里做错了什么。 If there's any more code needed, feel free to ask for it (but 99% of it is like in second link, only with really small changes). 如果需要更多代码,请随意提问(但99%的内容就像在第二个链接中,只有非常小的更改)。
Consider this topic as example of poor comunication. 将此主题视为糟糕通信的示例。 After hours of trying to make this work we made to work: 经过几个小时的尝试,我们开始工作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.