You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Rick Souza <ri...@digitro.com.br> on 2008/02/12 13:03:11 UTC

Problems with Https and Proxy

Hi, I'm trying to use the postmethod to conect a https site, but i need 
to conect the proxy first.
So I put the host, port, login and pass to connect and I see that 
everything is ok. When i try
to connect the https site, the error comes:  Connection is not Open!
But, if i try to connect any http site, it doesn't comes with error.
I'm trying this at the company that I work. When I test it at home, I 
can connect to the
https site without any error. I think that is happening because there's 
something wrong
with the proxy.

I'm gonna paste some part of the code:

        ...
        HttpClient client = new HttpClient();
       
        client.getHostConfiguration().setProxy("proxy", port);
        client.getState().setProxyCredentials(AuthScope.ANY,
                new UsernamePasswordCredentials("user", "pass"));

        PostMethod method = new PostMethod(url);

        method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
        new DefaultHttpMethodRetryHandler(3, false));

        
method.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);

        method.addParameter("user","user");
        method.addParameter("pass","pass");
        try {
        int status = client.executeMethod(method);
       ...

I can't understand what's wrong here.
I get the error when he try to execute the method post. The last line i 
paste here.

      


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Problems with Https and Proxy

Posted by Stephen More <st...@gmail.com>.
On Fri, Feb 15, 2008 at 5:19 AM, Rick Souza <ric.......r> wrote:
> The debug look like this:
>  2008/02/15 08:15:09:078 BRST [DEBUG] DefaultHttpParams - Set parameter
>  http.useragent = Jakarta Commons-HttpClient/3.0-rc2

Try updating to 3.0.1 or newer.


>  2008/02/15 08:15:46:015 BRST [DEBUG] HttpConnection - Open connection to
>  proxy.digitro.com.br:3128
>  2008/02/15 08:15:46:890 BRST [DEBUG] header - >> "CONNECT
>  acesso.uol.com.br:443 HTTP/1.1"

This seems strange....When I go through my proxy this "CONNECT" is
either a GET or POST.

Can you successfully get to this site using a regular browser ? If so
try capturing the network traffic to see what is different between the
one that works and the one that does not.

Firefox has a plugin called Tamper Data:
https://addons.mozilla.org/en-US/firefox/addon/966

Hope that helps.

-Steve More

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Problems with Https and Proxy

Posted by Rick Souza <ri...@digitro.com.br>.
The debug look like this:

2008/02/15 08:15:08:421 BRST [DEBUG] HttpClient - Java version: 1.5.0_07
2008/02/15 08:15:08:421 BRST [DEBUG] HttpClient - Java vendor: Sun 
Microsystems Inc.
2008/02/15 08:15:08:421 BRST [DEBUG] HttpClient - Java class path: 
C:\digitro\ambiente\workspaces\workspaceIdseg\SCInfoTeste\bin;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-httpclient-3.0-rc2.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-logging-1.0.4.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-collections-3.2.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-lang.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-validator.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-beanutils.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-codec-1.3.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-digester.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-discovery.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-email-1.0.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-fileupload-1.1.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-httpclient-3.1.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-io-1.3.jar;C:\digitro\ambiente\workspaces\workspaceIdseg\DGTIDSegWEB\WEB-INF\lib\commons-net.jar;C:\Documents 
and Settings\Rick\Desktop\xfire-all-1.2.6.jar
2008/02/15 08:15:08:437 BRST [DEBUG] HttpClient - Operating system name: 
Windows XP
2008/02/15 08:15:08:437 BRST [DEBUG] HttpClient - Operating system 
architecture: x86
2008/02/15 08:15:08:453 BRST [DEBUG] HttpClient - Operating system 
version: 5.1
2008/02/15 08:15:09:062 BRST [DEBUG] HttpClient - SUN 1.5: SUN (DSA 
key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; 
X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX 
CertPathBuilder; LDAP, Collection CertStores)
2008/02/15 08:15:09:062 BRST [DEBUG] HttpClient - SunRsaSign 1.5: Sun 
RSA signature provider
2008/02/15 08:15:09:062 BRST [DEBUG] HttpClient - SunJSSE 1.5: Sun JSSE 
provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1)
2008/02/15 08:15:09:062 BRST [DEBUG] HttpClient - SunJCE 1.5: SunJCE 
Provider (implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, 
PBE, Diffie-Hellman, HMAC)
2008/02/15 08:15:09:062 BRST [DEBUG] HttpClient - SunJGSS 1.0: Sun 
(Kerberos v5)
2008/02/15 08:15:09:062 BRST [DEBUG] HttpClient - SunSASL 1.5: Sun SASL 
provider(implements client mechanisms for: DIGEST-MD5, GSSAPI, EXTERNAL, 
PLAIN, CRAM-MD5; server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)
2008/02/15 08:15:09:078 BRST [DEBUG] DefaultHttpParams - Set parameter 
http.useragent = Jakarta Commons-HttpClient/3.0-rc2
2008/02/15 08:15:09:109 BRST [DEBUG] DefaultHttpParams - Set parameter 
http.protocol.version = HTTP/1.1
2008/02/15 08:15:09:125 BRST [DEBUG] DefaultHttpParams - Set parameter 
http.connection-manager.class = class 
org.apache.commons.httpclient.SimpleHttpConnectionManager
2008/02/15 08:15:09:125 BRST [DEBUG] DefaultHttpParams - Set parameter 
http.protocol.cookie-policy = rfc2109
2008/02/15 08:15:09:125 BRST [DEBUG] DefaultHttpParams - Set parameter 
http.protocol.element-charset = US-ASCII
2008/02/15 08:15:09:140 BRST [DEBUG] DefaultHttpParams - Set parameter 
http.protocol.content-charset = ISO-8859-1
2008/02/15 08:15:09:140 BRST [DEBUG] DefaultHttpParams - Set parameter 
http.method.retry-handler = 
org.apache.commons.httpclient.DefaultHttpMethodRetryHandler@16c79d7
2008/02/15 08:15:09:140 BRST [DEBUG] DefaultHttpParams - Set parameter 
http.dateparser.patterns = [EEE, dd MMM yyyy HH:mm:ss zzz, EEEE, 
dd-MMM-yy HH:mm:ss zzz, EEE MMM d HH:mm:ss yyyy, EEE, dd-MMM-yyyy 
HH:mm:ss z, EEE, dd-MMM-yyyy HH-mm-ss z, EEE, dd MMM yy HH:mm:ss z, EEE 
dd-MMM-yyyy HH:mm:ss z, EEE dd MMM yyyy HH:mm:ss z, EEE dd-MMM-yyyy 
HH-mm-ss z, EEE dd-MMM-yy HH:mm:ss z, EEE dd MMM yy HH:mm:ss z, 
EEE,dd-MMM-yy HH:mm:ss z, EEE,dd-MMM-yyyy HH:mm:ss z, EEE, dd-MM-yyyy 
HH:mm:ss z]
2008/02/15 08:15:46:015 BRST [DEBUG] HttpConnection - Open connection to 
proxy.digitro.com.br:3128
2008/02/15 08:15:46:890 BRST [DEBUG] header - >> "CONNECT 
acesso.uol.com.br:443 HTTP/1.1"
2008/02/15 08:15:46:890 BRST [DEBUG] HttpMethodBase - Adding Host 
request header
2008/02/15 08:15:46:890 BRST [DEBUG] header - >> "User-Agent: Jakarta 
Commons-HttpClient/3.0-rc2[\r][\n]"
2008/02/15 08:15:46:890 BRST [DEBUG] header - >> "Host: 
acesso.uol.com.br[\r][\n]"
2008/02/15 08:15:46:906 BRST [DEBUG] header - >> "Proxy-Connection: 
Keep-Alive[\r][\n]"
2008/02/15 08:15:46:906 BRST [DEBUG] header - >> "[\r][\n]"
2008/02/15 08:15:46:906 BRST [DEBUG] header - << "HTTP/1.0 407 Proxy 
Authentication Required[\r][\n]"
2008/02/15 08:15:46:937 BRST [DEBUG] header - << "Server: 
squid/2.6.STABLE5[\r][\n]"
2008/02/15 08:15:46:937 BRST [DEBUG] header - << "Date: Fri, 15 Feb 2008 
10:12:17 GMT[\r][\n]"
2008/02/15 08:15:46:937 BRST [DEBUG] header - << "Content-Type: 
text/html[\r][\n]"
2008/02/15 08:15:46:953 BRST [DEBUG] header - << "Content-Length: 
1358[\r][\n]"
2008/02/15 08:15:46:953 BRST [DEBUG] header - << "Expires: Fri, 15 Feb 
2008 10:12:17 GMT[\r][\n]"
2008/02/15 08:15:46:953 BRST [DEBUG] header - << "X-Squid-Error: 
ERR_CACHE_ACCESS_DENIED 0[\r][\n]"
2008/02/15 08:15:46:953 BRST [DEBUG] header - << "Proxy-Authenticate: 
Basic realm="Duvidas entre em contato com a ATI"[\r][\n]"
2008/02/15 08:15:46:953 BRST [DEBUG] header - << "X-Cache: MISS from 
proxy01.digitro.com.br[\r][\n]"
2008/02/15 08:15:46:968 BRST [DEBUG] header - << "X-Cache-Lookup: NONE 
from proxy01.digitro.com.br:3128[\r][\n]"
2008/02/15 08:15:46:968 BRST [DEBUG] header - << "Via: 1.0 
proxy01.digitro.com.br:3128 (squid/2.6.STABLE5)[\r][\n]"
2008/02/15 08:15:46:968 BRST [DEBUG] header - << "Proxy-Connection: 
close[\r][\n]"
2008/02/15 08:15:47:078 BRST [DEBUG] ConnectMethod - CONNECT status code 407
2008/02/15 08:15:47:203 BRST [DEBUG] AuthChallengeProcessor - Supported 
authentication schemes in the order of preference: [ntlm, digest, basic]
2008/02/15 08:15:47:203 BRST [DEBUG] AuthChallengeProcessor - Challenge 
for ntlm authentication scheme not available
2008/02/15 08:15:47:203 BRST [DEBUG] AuthChallengeProcessor - Challenge 
for digest authentication scheme not available
2008/02/15 08:15:47:218 BRST [INFO] AuthChallengeProcessor - basic 
authentication scheme selected
2008/02/15 08:15:47:218 BRST [DEBUG] AuthChallengeProcessor - Using 
authentication scheme: basic
2008/02/15 08:15:47:218 BRST [DEBUG] AuthChallengeProcessor - 
Authorization challenge processed
2008/02/15 08:15:47:218 BRST [DEBUG] HttpMethodDirector - Proxy 
authentication scope: BASIC 'Duvidas entre em contato com a 
ATI'@proxy.digitro.com.br:3128
2008/02/15 08:15:47:250 BRST [DEBUG] HttpMethodBase - Should close 
connection in response to directive: close
2008/02/15 08:15:47:250 BRST [DEBUG] HttpConnection - Connection is 
locked.  Call to releaseConnection() ignored.
2008/02/15 08:15:47:250 BRST [DEBUG] HttpMethodDirector - Authenticating 
with BASIC 'Duvidas entre em contato com a ATI'@proxy.digitro.com.br:3128
2008/02/15 08:15:47:250 BRST [DEBUG] HttpMethodParams - Credential 
charset not configured, using HTTP element charset
2008/02/15 08:15:47:281 BRST [DEBUG] HttpConnection - Releasing 
connection back to connection manager.
Exception in thread "main" java.lang.IllegalStateException: Connection 
is not open


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Problems with Https and Proxy

Posted by Stephen More <st...@gmail.com>.
What does the debug output look like ?

You can turn on debugging with the following code:

   System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.SimpleLog");
   System.setProperty("org.apache.commons.logging.simplelog.showdatetime",
"true");
   System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header",
"debug");
   System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient",
"debug");


-Steve More

On Tue, Feb 12, 2008 at 7:03 AM, Rick Souza <rick....r> wrote:
> Hi, I'm trying to use the postmethod to conect a https site, but i need
>  to conect the proxy first.
>  So I put the host, port, login and pass to connect and I see that
>  everything is ok. When i try
>  to connect the https site, the error comes:  Connection is not Open!
>  But, if i try to connect any http site, it doesn't comes with error.
>  I'm trying this at the company that I work. When I test it at home, I
>  can connect to the
>  https site without any error. I think that is happening because there's
>  something wrong
>  with the proxy.
>
>  I'm gonna paste some part of the code:
>
>         ...
>         HttpClient client = new HttpClient();
>
>         client.getHostConfiguration().setProxy("proxy", port);
>         client.getState().setProxyCredentials(AuthScope.ANY,
>                 new UsernamePasswordCredentials("user", "pass"));
>
>         PostMethod method = new PostMethod(url);
>
>         method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
>         new DefaultHttpMethodRetryHandler(3, false));
>
>
>  method.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
>
>         method.addParameter("user","user");
>         method.addParameter("pass","pass");
>         try {
>         int status = client.executeMethod(method);
>        ...
>
>  I can't understand what's wrong here.
>  I get the error when he try to execute the method post. The last line i
>  paste here.
>
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>  For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org