cURL / Mailing Lists / curl-users / Single Mail

curl-users

Curl command line + HTTPS + SSL prompt

From: Adrianyong <h_tere2000_at_yahoo.com>
Date: Fri, 27 Mar 2009 00:24:32 -0700 (PDT)

Hi all,

I'm trying to use curl to login to https website to do my daily batch work.
The process is as follows:
Browse https://www.website.com.myKey in the login username and password.Upload a file from my desktop.
Sounds simple. But browsing the HTTPS website invoke a request for a warning that certificate "issued to" does not belong this website. I click yes. Then i login with my name and password. Then i upload my file.

I tried the test code many times. But i can't seem to bring it to the next page or to login at the same time. Any ideas? I've google a lot of websites, and tweaked the code many times. I posted my various attempts below.

Was i trying to reinvent the wheel? hehe

Test code:
curl -k -d "username=administrator&password=password123&Submit=Submit" https://123.123.123.123/website/adminlogin/index.jsp

Result:
HTTP/1.1 200 OK
Date: Fri, 27 Mar 2009 06:37:37 GMT
Server: WebSphere Application Server/6.0
Content-Length: 2935
Set-Cookie: JSESSIONID=0000ymOGK0J4Q-kLfWV1G46FT7P:-1; Path=/
Content-Type: text/html;charset=ISO-8859-1
Content-Language: en-SG

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Company_Name</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="/Company_Name/css/css.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<FORM method="post" action="/Company_Name/AdminLogin">
<table width="750" border="0" cellpadding="0" cellspacing="0" height="100%" alig
n="center">
  <tr>
    <td width="618" height="100%" valign="top" align="center"><table width="100%
" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="2%">&nbsp;</td>
    <td width="96%">&nbsp;</td>
    <td width="2%">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="center"><img src="/Company_Name/images/logo.jpg" width="90" height="43"
></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td class="title" align="center">Internal Administrator Login<br><br></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><table width="602" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td valign="top" align="center"><table width="80%" border="0">
          <tr>
            <td class="tbl" align="center">
              <table width="95%" border="0" cellpadding="6" cellspacing="0">
                <tr>
                  <td class="tableContent" align="center">
                  <span class="error"></span>
                  <table width="80%" border="0" cellpadding="3" cellspacing="0">
                      <tr>
                        <td>User ID </td>
                        <td><input type="text" name="username">
                        </td>
                      </tr>
                      <tr>
                        <td>Password</td>
                        <td><input type="password" name="password">
                        </td>
                      </tr>
                      <tr>
                        <td colspan="2"><hr size="1" width="98%">
                        </td>
                      </tr>
                      <tr>
                        <td colspan="2" align="center"><input type="submit" name
="Submit" value="Submit" class="button">
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table></td>
      </tr>
    </table></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</td>
  </tr>
</table>
</form>
</body>
</html>

Below are my glorious attempts:

@echo off
REM curl -k https://123.123.123.123/website/adminlogin/index.jsp
REM curl -k --location-trusted -u "administrator:password123" https://123.123.123.123/website/adminlogin/index.jsp
REM curl -d "username=administrator&Submit=Submit&password=password123" --location-trusted https://123.123.123.123/website/adminlogin/index.jsp
REM curl -k -d "username=administrator&password=password123&Submit=Submit" https://123.123.123.123/website/adminlogin/index.jsp
REM curl -k https://123.123.123.123/website/adminlogin/index.jsp
REM curl -k -m 999 -data-binary "username=administrator&password=password123&Submit=Submit" https://123.123.123.123/website/adminlogin/index.jsp https://123.123.123.123/website/admin/welcome.jsp
REM curl -k -m 999 https://123.123.123.123/website/admin/welcome.jsp
REM curl -k -m 999 -d "username=administrator&password=password123&Submit=Submit" https://123.123.123.123/website/adminlogin/index.jsp
REM curl -k -m 999 https://123.123.123.123/website/admin/welcome.jsp
curl -k -m 999 -F "web=@login.html;type=text/html" --location-trusted https://123.123.123.123/website/admin/welcome.jsp
REM curl -k -d "username=administrator&password=password123&Submit=Submit" https://123.123.123.123/website/adminlogin/index.jsp

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-03-27