200 is a http-response code, only means the request comes & handled by server correcly, no error/exception, doesnt mean the username/password is correct.
try to use the browser to see how the login-request looks like in both cases or simply log the server-response. hth On Sat, Nov 2, 2013 at 2:39 PM, Horst Weigelt <[email protected]> wrote: > |I want to logon to a https URL using Apache HTTP Client 4.3 > > The login fails. However I receive HTTP status 200 when posting the > request. > > One issue for the login failure might be that there is no session ID send > in the| > |TLSv1 handshake protocol (Length: 0) > > That raises 2 questions: > 1) Is a session ID required for the login. If yes how can I set the > session ID. > 2) Is there something else missing in the Java code below (except for the > correct URL + login/password ;-) ) > > This question is also posted (more or less identically) in > http://stackoverflow.com/questions/19737218/session-id- > missing-in-https-post-using-apache-httpclient-4-3 > > > > HttpClientContext context= HttpClientContext.create(); > > /* to follow redirections */ RedirectStrategy redirectStrategy= > new LaxRedirectStrategy(); > > RequestConfig globalConfig= RequestConfig.custom() > .setCookieSpec(CookieSpecs.BEST_MATCH) > .build(); > RequestConfig localConfig= RequestConfig.copy(globalConfig) > .setCookieSpec(CookieSpecs.BROWSER_COMPATIBILITY) > .build(); > > try { > > SSLContext sslcontext= SSLContexts.custom() > .build(); > > SSLConnectionSocketFactory sslsf= new > SSLConnectionSocketFactory(sslcontext, > SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_ > VERIFIER); > > /* setup client for https and redirections */ > httpclient= HttpClients.custom() > .setRedirectStrategy(redirectStrategy) > .setSSLSocketFactory(sslsf) > .build(); > > > HttpPost httpost= new HttpPost("https://myURL"); > httpost.setConfig(localConfig); > > /* set login and password */ > httpost.setEntity(new UrlEncodedFormEntity(login_and_passwd, > Consts.UTF_8)); > > CloseableHttpResponse httpresponse= httpclient.execute(httpost); > > } > } finally { > httpclient.close(); > } > return httpclient; > > > Thanks for any help > Horst > > > | > >
