joshdholtz / Sentry-Android

[Deprecated] Use official "raven-java" library
https://github.com/getsentry/sentry-java
MIT License
180 stars 48 forks source link

Fixed a problem with access to SSL. #19

Closed Kras4ooo closed 9 years ago

Kras4ooo commented 9 years ago

I had a problem accessing SSL, which are untrusted. Gave me 403 ERROR. This code fix my problem and decided to share it if it will benefit someone.

joshdholtz commented 9 years ago

@Kras4ooo Was this because you were trying to hit your own hosted version of Sentry?

Kras4ooo commented 9 years ago

I uploaded a sentry that virtual host. There are several projects under management because getsentry.com restrictions. Also the host that has ssl is untrusted, but not really untrusted. Otherwise version of Sentry is 6.0.0

joshdholtz commented 9 years ago

@Kras4ooo My one concern with this PR is I believe (I could be wrong) that this will trust anything - which I don't think I want it do by default as that is potentially insecure. Can you add flag on the Sentry client that defaults to not using this that but can be changed by the developer to use it if they want?

An if statement with that flag would then wrap this line https://github.com/joshdholtz/Sentry-Android/pull/19/files#diff-79ff5c611f0f93f64c7ba84ddeefc48eR380

Kras4ooo commented 9 years ago

Well I will add this if statement to be specified by the developer that wants to use this option or not.

joshdholtz commented 9 years ago

@Kras4ooo Thanks!! I will take a look when you push the new code :grin:

Kras4ooo commented 9 years ago

Added if statement that checks whether set in verify_ssl dsn link. When set to 0, then it is assumed that ssl is untrusted. Any other number, or if you do not set this parameter will be assumed that the link is trusted.

Example (untrusted): http://your-dsn?verify_ssl=0 Example (trusted): http://your-dsn?verify_ssl=1 Example (trusted): http://your-dsn

joshdholtz commented 9 years ago

@Kras4ooo Instead of putting it in the URL, can you make it a boolean on the Sentry class? Below is an example of what I'm thinking...

// How to configure your client
Sentry.setVerifySSL(false);

// Modifications that are needed for Sentry
public class Sentry { 
     // other variables are here
    private boolean verifySSL = true;

    private static void setVerifySSL(boolean verifySSL) {
        Sentry.getInstance().verifySSL = verifySSL;
    }

   // In that doCaptureEventPost method
    httpClient = new DefaultHttpClient();
    if (!Sentry.getInstance().verifySsl) {
        httpClient = getHttpsClient(httpClient);
    }

}

Let me know if you have any questions on what I am suggesting :smile:

Kras4ooo commented 9 years ago

I decided to keep the convention by Raven version Version 4.1.0. and so I added verify_ssl in url, but there is no problem and added as a method :)

joshdholtz commented 9 years ago

@Kras4ooo Ah, I was not actually aware of that verify_ssl in the URL - always good to learn new things :blush: You can keep it that way then!

joshdholtz commented 9 years ago

I will play with that verify_ssl query parameter commit tomorrow for ya!

Kras4ooo commented 9 years ago

Thanks!!! :)

joshdholtz commented 9 years ago

@Kras4ooo Works good man! :+1: Want me to merge this in?

Kras4ooo commented 9 years ago

Yes there is no problem :)

joshdholtz commented 9 years ago

:boom: Thanks for help! Do you have a Twitter account? I like to mention people in my tweets with updates :grin:

Kras4ooo commented 9 years ago

Yes I have but little is a poor tweets :smile: @Kras4ooo