[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 543
  • Last Modified:

curl on Windows with SSL

I downloaded the cacert.pem file (I placed it within an editor, so it is currently in CR/LF format on WInodws, not the normal Unix format)

I type the cacert.pem file

C:\curl>type \curl\cacert.pem   | more
## Bundle of CA Root Certificates
## Certificate data from Mozilla downloaded on: Wed Aug 20 03:12:04 2014
## This is a bundle of X.509 certificates of public Certificate Authorities
## (CA). These were automatically extracted from Mozilla's root certificates
## file (certdata.txt).  This file can be found in the mozilla source tree:
## http://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/
## It contains the certificates in PEM format and therefore
## can be directly used with curl / libcurl / php_curl, or with
## an Apache+mod_ssl webserver for SSL client authentication.
## Just configure this file as the SSLCACertificateFile.
## Conversion done with mk-ca-bundle.pl verison 1.22.
## SHA1: bf2c15b3019e696660321d2227d942936dc50aa7

GTE CyberTrust Global Root

Open in new window

Then I try the following command:

C:\curl>curl -H "Content-Type: application/json" -d @input3.txt --cacert /curl/c
acert.pem https://www.google.com
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-wi
  <title>Error 405 (Method Not Allowed)!!1</title>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{backgrou
nd:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height
:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/error
s/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflo
w:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (m
}}#logo{background:url(//www.google.com/images/errors/logo_sm_2.png) no-repeat}@
media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.
com/images/errors/logo_sm_2_hr.png) no-repeat 0% 0%/100% 100%;-moz-border-image:
url(//www.google.com/images/errors/logo_sm_2_hr.png) 0}}@media only screen and (
rrors/logo_sm_2_hr.png) no-repeat;-webkit-background-size:100% 100%}}#logo{displ
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>405.</b> <ins>ThatΓÇÖs an error.</ins>
  <p>The request method <code>POST</code> is inappropriate for the URL <code>/</
code>.  <ins>ThatΓÇÖs all we know.</ins>

Open in new window

What is the problem with this command?

Anthony Lucia
Anthony Lucia
  • 2
1 Solution
Just try a simple test to see if the SSL is being negotiated

curl https://www.google.com

And you should get back the Google search page code.
Anthony LuciaAuthor Commented:
I tried the following:

C:\curl>curl https://www.google.com
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

Open in new window

So yes, it appears that the SSL is being negotiated, but unsucessfully
Forgot to add the cert path - change /curl/cacert.pem to the absolute path e.g. c:/path/file

curl  --cacert /curl/cacert.pem https://www.google.com

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now