One Star

How to send POST request via HTTPS

Hi,
I'm trying to access an HTTPS web page which needs some POST parameters in order to download a generated file.
HTTPS connection requires authentication, and it throws a certificate warning which can be ignored.
I tried using tHttpRequest but it fails on HandShake, so I added tJava component so that it ignores certificate:
System.setProperty ("jsse.enableSNIExtension", "false");
javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(
new javax.net.ssl.HostnameVerifier(){

public boolean verify(String hostname,
javax.net.ssl.SSLSession sslSession) {
if (hostname.equals("mydomain")) {
return true;
}
return false;
}
});

Even after I ignore certificate I get following error:
Exception in component tHttpRequest_1
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed
at sun.security.ssl.Alerts.getSSLException(Unknown Source)

Any ideas about how to stablish proper HTTPS connection?
I also read about tWebDavGet but it doesn't fit my needs since it doesn't let you specify POST parameters.
Any help will be appreciated!
6 REPLIES
Community Manager

Re: How to send POST request via HTTPS

Hi Jcoves
Have a try to use tFileFetch component which supports HTTPS connections, you can set authentication in the advanced settings panel of component.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: How to send POST request via HTTPS

Hi Shong,
I finally managed to authenticate throuh both tFileFetch and tHttpRequest by passing parameters to the login page. After that I receive an HTML file which claims user is properly authenticated.
Even though i managed to authenticate, when I execute second step (which would be donwloading file) authentication is lost. It seems to me, first component autheticates properly and closes connection, doesn't retain authentication when second component executes. I would need a component which authenticates first and immediately after sends request to download file.
Is there any way to retain HTTPs login (via cookie?) or to execute both operations (authentication + post call to download file) in a single component?
Thanks!
Community Manager

Re: How to send POST request via HTTPS

Hi
Is there any way to retain HTTPs login (via cookie?) or to execute both operations (authentication + post call to download file) in a single component?

How do you set the URI of tFileFetch component? To me, tFileFetch component creates the HTTPS connection and then download the specified file.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: How to send POST request via HTTPS

Hi Shong,
Thanks for your answer. In my case, "needs authentication" check doesn't authenticate properly so I must point at LOGIN form page and send both username and password to sucessfully log in. Therefore, I only can execute one action which is login, trying to download file would be a second step.
Thanks
One Star

Re: How to send POST request via HTTPS

Hi all,
I have the same kind of issue :
1. TFileFetch_1 to POST user & password and getting a cookie : OK
2. TFileFetch_2 to GET another page in connecting mode with reading the former cookie : OK ... but NOK
I have no error so far, but the 2nd page still provides a "You are not connected." message.
For the 1st one, when using the form to authenticate, I'm redirect to the index page with the no-connect message. But i checked that the cookie still contains the right SESSION_ID, a valid one.
The TFileFetch_1 has redirect option checked.
I'm just wondering if the cookie is really sent along the GET HTTP request.
TOS 5.2.1
Here is the answer-console message (checked option) :
connecting to socket on port 4049
connected
Status Line: HTTP/1.1 200 OK
*** Response Header ***
Date: Thu, 01 Aug 2013 13:25:20 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.2.10
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Set-Cookie: PHPSESSID=<<xxxxx>>; path=/
Status Line: HTTP/1.1 200 OK
*** Response Header ***
Date: Thu, 01 Aug 2013 13:25:21 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.2.10
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
disconnected

Thanks for your help and ideas/leads !
Benet
Community Manager

Re: How to send POST request via HTTPS

Hi Shong,
Thanks for your answer. In my case, "needs authentication" check doesn't authenticate properly so I must point at LOGIN form page and send both username and password to sucessfully log in. Therefore, I only can execute one action which is login, trying to download file would be a second step.
Thanks

In the first tFileFetch, check the 'save cookie' option and input a file path to save the cookie, and check the 'read cookie' on the second tFileFetch component that will download file.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business