69

I am developing and I need to access https://localhost. I know the certificate will not match. I just want curl to ignore that. Currently it gives me the following error message:

curl: (51) SSL peer certificate or SSH remote key was not OK

Is it possible to tell curl to perform the access anyway?

86

Yeah, you can do that. From curl --help or man curl:

-k, --insecure

(SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers. All SSL connections are attempted to be made secure by using the CA certificate bundle installed by default. This makes all connections considered "insecure" fail unless -k, --insecure is used.

See this online resource for further details: http://curl.haxx.se/docs/sslcerts.html

| improve this answer | |
  • 3
    right, I just found it myself. I looked for it yesterday and it was not there! :) – blueFast Jan 16 '13 at 23:12
  • 9
    Whoa! What's with the snarky reply? – Darth Egregious Jul 29 '14 at 16:21
  • 8
    Downvoted for the snarky response. If you don't want to answer a question, just don't. – Michael Jul 6 '16 at 17:13
  • 3
    @Michael answering the question and asking people to RTFM are not mutually exclusive options (as I believe my answer to this question perfectly demonstrates). You can do both – Mathias R. Jessen Jul 6 '16 at 17:22
  • 7
    @MathiasR.Jessen you can indeed, but usually a less snarky tone is appreciated by most people – Michael Jul 6 '16 at 17:33
20

curl -k or curl --insecure does NOT fix this particular error condition: "curl: (51) SSL peer certifcate

| improve this answer | |
  • 3
    The SSL peer certificate error occurs when validation of the trust chain (not the actual certificate) fails. My first recommendation would be to update the CA bundle on the machine – Mathias R. Jessen Jul 30 '14 at 10:35
1

If you truly want to disable curl SSL verification, by default, for ALL use cases, you can do as suggested in this Unix stack exchange answer:

$ echo insecure >> ~/.curlrc

Now should you do this? No, as this is avoiding security checks you should have in place... but if you really really want to do this, caveat emptor!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.