Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 21 down vote accepted

Yeah, you can do that, as curl --help or man curl would have told you:

-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:

share|improve this answer
right, I just found it myself. I looked for it yesterday and it was not there! :) – jeckyll2hide Jan 16 '13 at 23:12
Whoa! What's with the snarky reply? – user973810 Jul 29 '14 at 16:21
I still see the "(51) SSL peer certificate ... was not ok" message with -k – Joao Costa Jan 12 at 10:40

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

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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