[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1903?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16357342#comment-16357342
 ] 

Michael Pujos commented on HTTPCLIENT-1903:
-------------------------------------------

While we're on the topic of making HttpComponents work better for Android users:

 

Currently any Android developer that wants to use HttpComponents needs to 
repackage it in a different package root:

 

for example org.apache.http....  =>  com.mycompany.org.apache.http

 

This prevents to add dependencies directly in Gradle (or Maven), as the steps 
are:

 
 * repackage each needed  jar using jarjar, using a new package root
 * mvn install:install-file   each repackaged jar, using a tweaked artifactId
 * use that in Gradle/Maven

 

This can somewhat be automated but I think HttpComponents would be more popular 
with Android devs if they could just add (Gradle):(

 

dependencies {

   ...
    implementation 'org.apache.httpcomponents:httpclient:4.5.5'

  ...

}

 

for that to be possible, the org.apache.http package root should be replaced 
with something else to not collide with the (unfortunate)

same root present in the Android platform API. I was thinking of 
org.apache.httpcomponents. Would that be something that could be considered

for 5.0 or is it totally out of question ? I think doing this would make 
HttpComponents much more popular with Android devs

as it would be just like using any other library, instead of the convoluted 
steps required today (which probably most Android devs

do not think is even possible).

 

 

> DefaultHostnameVerifier crashes on Android due to inexistent javax.naming 
> classes
> ---------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1903
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1903
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>    Affects Versions: 4.5.5
>            Reporter: Michael Pujos
>            Assignee: Oleg Kalnichevski
>            Priority: Minor
>             Fix For: 4.6 Alpha1
>
>
> I'm using HttpClient on Android, repackaged to avoid conficting with the 
> platform's org.apache old packages.
> It works fine, except that making any https request will crash using the 
> defaults.
> The reason is that DefaultHostnameVerifier uses javax.naming.* classes, which 
> are not present on Android.
> So to be able to make https request, the default hostname verifier must be 
> replaced. For example:
>  
> httpClient = HttpClients.custom()
>                 .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
>                 .build();
>  
> Using NoopHostnameVerifier is rarely a good idea, so for the time being I 
> have replaced it with and older version of BrowserCompatHostnameVerifier that 
> doesn't internally call DefaultHostnameVerifier.
>  
> Ideally, I'd like DefaultHostnameVerifier to detect dynamically if 
> javax.naming.* classes are available, and switch to an alternate method not 
> using them if they are not. That way, HttpClient would work out of the box 
> for Android users.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to