You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Endrigo Antonini (JIRA)" <ji...@apache.org> on 2008/02/08 14:33:10 UTC
[jira] Created: (HTTPCLIENT-744) HTTPClient is not using Protocol
configured in HostConfiguration when using mutual Auth in connections
HTTPClient is not using Protocol configured in HostConfiguration when using mutual Auth in connections
------------------------------------------------------------------------------------------------------
Key: HTTPCLIENT-744
URL: https://issues.apache.org/jira/browse/HTTPCLIENT-744
Project: HttpComponents HttpClient
Issue Type: Bug
Components: HttpClient
Affects Versions: 3.1 Final
Reporter: Endrigo Antonini
Priority: Critical
I'm using HTTClient to access a WS which are using mutual authentication.
So I have to "create" a https protocol that will do the Handshake process.
Every example that I found on Internet, it was registering this protocol as the default protocol of HTTPS connections, but in my system this is a big problem, because i'm connecting others https urls that are not using mutual authentication. Example:
Protocol.registerProtocol("https", myprotocol);
So I found a way to set the Protocol in the HostConfiguration doing like this:
SecureProtocolSocketFactory auth = new AuthSSLProtocolSocketFactory(file.toURI().toURL(), pass, null, null);
Protocol trustHttps = new Protocol(url, (ProtocolSocketFactory) auth, certificate.getPort());
HostConfiguration hostConfiguration = new HostConfiguration();
hostConfiguration.setHost(url, certificate.getPort(), trustHttps);
httpclient.execute(hostConfiguration,method);
But i was still having the problem.
I found inside class HTTClient the error.
It's on the method "executeMethod(HostConfiguration hostconfig, final HttpMethod method, final HttpState state)" on line "hostconfig.setHost(uri)".
If you trace the method setHost(URI), you will see that this method is getting the standard protocol (that is register in Protocol) to access this url.
I fixed this problem changing this part of the code to:
hostconfig = (HostConfiguration) hostconfig.clone();
if (hostconfig.getProtocol() == null) {
if (uri.isAbsoluteURI()) {
hostconfig.setHost(uri);
}
} else {
int port = uri.getPort();
if (port <= 0) port = hostconfig.getProtocol().getDefaultPort();
hostconfig.setHost(uri.getHost(), uri.getPort(), hostconfig.getProtocol());
}
This solution it's running in my system and it's working.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
[jira] Closed: (HTTPCLIENT-744) HTTPClient is not using Protocol
configured in HostConfiguration when using mutual Auth in connections
Posted by "Roland Weber (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Roland Weber closed HTTPCLIENT-744.
-----------------------------------
Resolution: Invalid
The code behaves exactly as intended, and exactly as explained for plenty of other reports:
https://issues.apache.org/jira/browse/HTTPCLIENT-684
https://issues.apache.org/jira/browse/HTTPCLIENT-683
https://issues.apache.org/jira/browse/HTTPCLIENT-658
https://issues.apache.org/jira/browse/HTTPCLIENT-648
https://issues.apache.org/jira/browse/HTTPCLIENT-558
It has been behaving like this at least since 3.0 RC3:
https://issues.apache.org/jira/browse/HTTPCLIENT-456
There is a clean workaround available since 3.1 RC1:
https://issues.apache.org/jira/browse/HTTPCLIENT-634
> HTTPClient is not using Protocol configured in HostConfiguration when using mutual Auth in connections
> ------------------------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-744
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-744
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpClient
> Affects Versions: 3.1 Final
> Reporter: Endrigo Antonini
> Priority: Critical
>
> I'm using HTTClient to access a WS which are using mutual authentication.
> So I have to "create" a https protocol that will do the Handshake process.
> Every example that I found on Internet, it was registering this protocol as the default protocol of HTTPS connections, but in my system this is a big problem, because i'm connecting others https urls that are not using mutual authentication. Example:
> Protocol.registerProtocol("https", myprotocol);
> So I found a way to set the Protocol in the HostConfiguration doing like this:
> SecureProtocolSocketFactory auth = new AuthSSLProtocolSocketFactory(file.toURI().toURL(), pass, null, null);
> Protocol trustHttps = new Protocol(url, (ProtocolSocketFactory) auth, certificate.getPort());
> HostConfiguration hostConfiguration = new HostConfiguration();
> hostConfiguration.setHost(url, certificate.getPort(), trustHttps);
> httpclient.execute(hostConfiguration,method);
> But i was still having the problem.
> I found inside class HTTClient the error.
> It's on the method "executeMethod(HostConfiguration hostconfig, final HttpMethod method, final HttpState state)" on line "hostconfig.setHost(uri)".
> If you trace the method setHost(URI), you will see that this method is getting the standard protocol (that is register in Protocol) to access this url.
> I fixed this problem changing this part of the code to:
> hostconfig = (HostConfiguration) hostconfig.clone();
> if (hostconfig.getProtocol() == null) {
> if (uri.isAbsoluteURI()) {
> hostconfig.setHost(uri);
> }
> } else {
> int port = uri.getPort();
> if (port <= 0) port = hostconfig.getProtocol().getDefaultPort();
>
> hostconfig.setHost(uri.getHost(), uri.getPort(), hostconfig.getProtocol());
> }
> This solution it's running in my system and it's working.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org