25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

cURL error 51 (SSL peer certificate) – Fix it easily

by | Jun 20, 2020

cURL uses different network protocols to transfer data. It by default tries to establish a secure connection by verifying the SSL certificates.

But, when it fails to find a valid certificate, the connection will end up with the cURL error 51.

At Bobcares, we often get requests to fix cURL errors, as a part of our Server Management Services. Today, let’s discuss some tips to fix this cURL error.

 

Why does cURL error 51(SSL peer certificate) occur?

cURL is an open-source command-line tool that transfers data using network protocols. When cURL tries to connect with a remote service, it uses secure protocols like HTTPS.

When there is a problem with the SSL certificate, it ends up in cURL error 51. And we solve this by fixing the certificates.

Recently, one of our customers approached us with the below error message.

cURL error 51 (SSL peer certificate)

Let’s see the possible ways to fix this error.

 

How to fix the cURL error 51(SSL peer certificate)?

To fix this error our Support Team usually fixes the certificates used. But there is an alternate option to ignore the cURL verification which we don’t recommend as it is not secure.

 

Check the cURL SSH connection

Initially, we cross-check the fingerprint of the server in the /.ssh/known_hosts file. We also make sure that the curl version and SSH version uses the same fingerprint.

Hence the cURL can connect using SSH without any error.

 

Check the SSL certificate

Whenever users approach us with this error, we check the certificates in the server. Sometimes an empty certificate file can be a problem. Hence we ask users to use a valid certificate.

Also using the CURLOPT_SSL_VERIFYPEER option in the cURL request need a valid SSL certificate. Here the self-signed certificate may not work.

So we ask the users to use a valid certificate for a secure connection.

 

Ignore verification

Developers often want to test URL requests for their applications. And cURL errors are most obvious here.

Especially when they try to access a secure domain that uses HTTPS protocol. Usually, this can end up in cURL error 51.

In such cases, just for testing, we ask them to disable the cURL certificate verification. For this, we ask them to use, -k or --insecure options in the command line requests.

The insecure option allows cURL to perform insecure SSL connections and transfers.

Alternatively, to ignore verification we ask then to change a few settings in the cURL request code. And they are,

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);

But using this option in live websites can lead to many security threats like man-in-the-middle attacks. Hence we highly recommend avoiding this usage, unless for testing purposes.

 

[Need assistance in fixing cURL errors? – Our Experts are available 24/7.]

 

Conclusion

The cURL error 51 SSL peer certificate, indicates that there is a problem with SSL Certificate. Today, we saw how our Support Engineers fixed the error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF