cURL / Mailing Lists / curl-users / Single Mail

curl-users

Using curl in a Java app to simulate an SSL POST

From: Ryan Sutter <rockboy_at_nucleargopher.com>
Date: Mon, 19 Jun 2000 16:21:53 -0500

Hi,

I'm using curl to provide me with some SSL related functionality in a
Java app by doing a runtime.exec(curl command) type thing.
Specifically, I am trying to post to an SSL server. I know that there
are various Java libraries out there purporting to add SSL functionality
to java.net but I have yet to get any of them to work as intended. So,
I'm trying this. The command I am executing is:

/usr/local/bin/curl -i -F "cmd=login" -F
"email=rockboy_at_nucleargopher.com" -F "password=somepassword"
https://login.mp3.com/login

When I do it from the command line, I get the following:

HTTP/1.1 302 Found
Date: Mon, 19 Jun 2000 20:17:58 GMT
Server: Stronghold/2.4.2 Apache/1.3.6 C2NetEU/2412 (Unix) yasl/2.9
mod_backwash/3.00 mod_perl/1.24 mod_oas/4.63b
Set-Cookie:
MP3_ID=M-149708935-345753817-1600061687-961445878-rLrQHKod5OFA0H9GnkKMOg;
domain=.mp3.com; path=/; expires=Wed, 19-Jun-2002 20:17:58 GMT
Set-Cookie: MP3_EMAIL=rockboy%40nucleargopher.com; domain=.mp3.com;
path=/; expires=Thu, 17-Jun-2010 20:17:58 GMT
Set-Cookie:
MP3_SESS=U-149708935-249854-71514818-0-961445878-YdBM1aBHgGXpKiei_wruTA;
domain=.mp3.com; path=/Location:
Connection: close
Content-Type: text/plain

Exactly what I would expect, a successful login. However, I pass the
exact same command string into a Java runtime.exec() call as follows:

// Java code snippet

String cmd = "/usr/local/bin/curl -i -F \"cmd=login\" -F \"email=" +
userName + "\" -F \"password=" + password + "\"
https://login.mp3.com/login";

System.out.println(cmd);
Runtime r = Runtime.getRuntime();

Process p = r.exec(cmd);

// end Java code snippet

And I get a totally different output (which is too long to paste here).
It's the result I would expect from a failed login, which is a repeat of
the login page. So, it appears that somehow curl is not getting the
parameters as I would expect it to. Now, I realize that this is more a
Java problem than a curl problem, but I'm hoping that somebody out there
has successfully managed to POST with curl from a Java app and can tell
me what I can do differently...

Thanks in advance..

Ryan
Received on 2000-06-19