Using curl in a Java app to simulate an SSL POST
Date: Mon, 19 Jun 2000 16:21:53 -0500
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"
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
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
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 + "\"
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..
Received on 2000-06-19