-
Notifications
You must be signed in to change notification settings - Fork 4.1k
How Do Request a https url #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As I now it's just a normal request? If you look into source code you wiil see this implemented. |
Hello, This is the code I use for an https connection : /// We initialize a default Keystore
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
// We load the KeyStore
trustStore.load(null, null);
// We initialize a new SSLSocketFacrory
MySSLSocketFactory socketFactory = new MySSLSocketFactory(trustStore);
// We set that all host names are allowed in the socket factory
socketFactory.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
// We initialize the Async Client
AsyncHttpClient client = new AsyncHttpClient();
// We set the timeout to 30 seconds
client.setTimeout(30*1000);
// We set the SSL Factory
client.setSSLSocketFactory(socketFactory);
// We initialize a GET http request
client.get("https://www.github.com", new AsyncHttpResponseHandler() {
// When success occurs
public void onSuccess(String response){
// We print the response
System.out.println(response);
}
}); This way will trust all certificates. It's not the best way to do, but it's the easiest way to do, especially if you want to trust a self-signed certificate. Hope it helps. |
good |
@herfrayg thanks for the sample |
Added the implementation of MySSLSocketFactory
|
@vinceyuan saying what? If you look at https://github.com/loopj/android-async-http/blob/master/library/src/main/java/com/loopj/android/http/AsyncHttpClient.java#L160 We've already added the all-trust sslsocketfactory, you can turn it on by using constructor |
@vinceyuan great, the related issue is fixed in latest master branch, I'll push 1.4.5 soon, probably around christmas, but you can use the master if you want already. |
Hi |
@raul1991 |
Cool , ill wait for it. |
Thanks for new sample , but can you guide me like if i have to use the keystore code and certificate things in every request that i make(yes, i have to make my whole application ssl savvy) or i can make a singleton for this HttpsClient and make a request via it every time. |
印象笔记无法提交笔记,原因如下: 本月帐户上传流量已经达到上限。 原消息详情: 为了防止邮件过多,接下来的360分钟内,你将不会收到报错回复。 升级到印象笔记高级帐户,可以发送的邮件数量将从50封提升到200封。
|
@raul1991 you can create singleton (static instance of AsyncHttpClient) and load it with keystore once, and use it for every request afterwards. |
印象笔记无法提交笔记,原因如下: 本月帐户上传流量已经达到上限。 原消息详情: 为了防止邮件过多,接下来的360分钟内,你将不会收到报错回复。 升级到印象笔记高级帐户,可以发送的邮件数量将从50封提升到200封。
|
thanks ... ill try it soon. |
Hi Currently i use 1.4.5 version and have this kind of issue, looks like I have a problems in SSL level. Using Samsung Galaxy 5, Android version 4.4.2. Here's the log: Build: samsung/k3gxx/k3g:4.4.2/KOT49H/G900HXXU1ANG3:user/release-keys Build fingerprint: 'samsung/k3gxx/k3g:4.4.2/KOT49H/G900HXXU1ANG3:user/release-keys' |
@korkag since we do not utilize any native components, I'm afraid this log comes from faulty Samsung ROM |
Same issue on httpOk |
@douglasmarques cool, that means, it's issue of underlying ROM / libssl-libc implementation |
I am having the same issue. Want to talk to an SSL Server and I get a
error even with the code @gahfy and @vinceyuan posted to allow all Certificates. Do you have any idea on how to debug that? |
@georgbachmann me neither, "Connection closed by peer", could be problem of allowed ciphers/key-exchange algorithms, see compatibility settings and validate your ssl endpoint. |
The validation with the link you send got this:
so might it really be a server issue? Connecting to the API from iOS works... but not from Android?!? |
@georgbachmann yes, that's possible, can you disclose endpoint url for me to check it? |
sorry... I can't... I know that's counter-productive... but it's a client project and so I can't tell you... :( |
@georgbachmann well, than discuss it with your sysadmin, who takes care of server configuration, maybe they will be able to come up with solution. I'm not able under such conditions. |
ok @smarek thanks anyway!!! |
Mention in my code i did a lot of requests in same time (was downloading a lot of images in parallel during list scrolling without canceling not relevant) - wrong implementation in client side. Changed the logic to make (limit the max concurrent connection for example ). Solved the SSL issue. |
Thank you @gahfy your comment is clear and the code Works perfectly. |
I'm also seeing the same issue as @korkag
in other words...
when posting asyncronously to a web server using post() and https. I am posting ten messages at once, and the issue only appears on Samsung Galaxy devices using android 4.4. is this related to either of these, perhaps? what is the status of loopj and ALPN support, if this is even related? https://code.google.com/p/android/issues/detail?id=74964 @smarek this definitely seems directly related to the samsung galaxy devices and the libssl-libc implementation in android 4.4 - however, the okhttp guys seem to have related this (or a similar issue?) to broken ALPN support. so this is why I was wondering what loopj's library status was with regards to that; as in, is loopj using this for https connections? |
Thank you very much for sharing. |
@gahfy How I can load a keystore so the server can trust me? Because with that method i can't load the client certificate and server-side i get message of empty chain. |
How Do Request a https url
The text was updated successfully, but these errors were encountered: