Skip to content
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

Add support for self signed certificates #3

Closed
koush opened this issue Jun 3, 2013 · 17 comments
Closed

Add support for self signed certificates #3

koush opened this issue Jun 3, 2013 · 17 comments

Comments

@koush
Copy link
Owner

koush commented Jun 3, 2013

Need support for custom SSL Context and TrustManagers for use during SSL handshaking.

@koush
Copy link
Owner Author

koush commented Jun 5, 2013

Fixed with:

Ion.getDefault(getContext()).getHttpClient().getSSLSocketMiddleware().setTrustManagers(...);
Ion.getDefault(getContext()).getHttpClient().getSSLSocketMiddleware().setSSLContext(...);

Fix was in AndroidAsync:
koush/AndroidAsync@968638d

@koush koush closed this as completed Jun 5, 2013
@koush
Copy link
Owner Author

koush commented Jun 5, 2013

This test case is also a good sample:

koush/AndroidAsync@968638d#L6R1

@yolapop
Copy link

yolapop commented Nov 27, 2013

Excuse me for asking,
this implementation is basically like "trust all incoming certificate" and not some specific certificate, right?

@koush
Copy link
Owner Author

koush commented Nov 27, 2013

It's an implementation to trust a specific cert.

@yolapop
Copy link

yolapop commented Nov 27, 2013

But it doesn't load a specific CA from file, or somewhere, like in here https://developer.android.com/training/articles/security-ssl.html#UnknownCa, so how does it trust from specific cert?

@koush
Copy link
Owner Author

koush commented Nov 27, 2013

It does exactly that:

koush/AndroidAsync@968638d#diff-f1b421e2e337ad983791aaef62f7de28R33

See the bit where it sets up it's own trust manager and loads a self signed cert.

@yolapop
Copy link

yolapop commented Nov 27, 2013

Oh, shit. I realized that I misread second comment (or first) this whole time.
Thank you for clarification, Koush.

@rvanzon
Copy link

rvanzon commented Mar 10, 2014

Is there maybe a simple example showing how to use this when using Ion to connect to a RESTful server using self signed certificates?

@ghost
Copy link

ghost commented Jul 22, 2014

As Ion.with(...) uses a new HttpClient for each call - how can we set a trustManager to be used for all Ion requests?

@anti43
Copy link

anti43 commented Feb 20, 2015

EDIT
@mannaz I got Ion.with to work like this:

    Ion ion = Ion.getDefault(c);
    ion.configure().createSSLContext("TLS");
    ion.getHttpClient().getSSLSocketMiddleware().setSSLContext(sslContext);
    ion.getHttpClient().getSSLSocketMiddleware().setTrustManagers(trustManagers);

( Ion.getDefault(c) is used in Ion.with{})

@koush
Copy link
Owner Author

koush commented Feb 20, 2015

ion uses the same http client every call.

@anti43
Copy link

anti43 commented Feb 21, 2015

@koush yes, but as the examples setup

AsyncHttpClient.getDefaultInstance()

and Ion.getDefault(c) is on

new AsyncHttpClient(new AsyncServer("ion-" + name));

the example code does not match the usage of Ion.with ..
That was what was confusing here I guess.

@koush
Copy link
Owner Author

koush commented Feb 21, 2015

ion.with calls into ion.getDefault.

@koush
Copy link
Owner Author

koush commented Feb 21, 2015

oh, you were assuming that ion uses the default asynchttpclient. nah, it has it's own.

@HughJeffner
Copy link

Is there a reason .setTrustManagers(...) must be called as well? I thought the SSLContext is initialized with a set of trust managers, this seems like a duplication of effort.

@ibnux
Copy link

ibnux commented Mar 4, 2017

i use Cloudflare Free SSL and getting Error
this is how i resolve it https://gist.github.com/ibnux/4bf68e16e1228b6568a349c583d1cd32

@muhammad-naderi
Copy link

for future reference : https://gist.github.com/muhammad-naderi/fad2c163ac61e0b7282209c07f5dadf5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants