How to Fix 'Peer Certificate Cannot be Authenticated with Given CA Certificates' Error: A Comprehensive Guide

If you are a developer, you have probably encountered the "Peer Certificate Cannot be Authenticated with Given CA Certificates" error while working with SSL/TLS certificates. This error occurs when your system does not trust the certificate provided by the server you are trying to connect to. In this guide, we will provide you with a step-by-step solution to fix this error.

What is Peer Certificate Authentication?

Peer certificate authentication is a process that verifies the identity of a server using SSL/TLS certificates. These certificates are issued by trusted Certificate Authorities (CAs) and contain information about the server's identity, such as its name and public key. When a client connects to a server using SSL/TLS, it requests the server's certificate and verifies its authenticity by checking the CA that issued it.

What Causes the 'Peer Certificate Cannot be Authenticated with Given CA Certificates' Error?

The "Peer Certificate Cannot be Authenticated with Given CA Certificates" error occurs when your system does not trust the CA that issued the server's certificate. This can happen for several reasons, such as:

  • The CA is not included in your system's trusted CA store.
  • The server's certificate is self-signed or issued by an untrusted CA.
  • The CA's root certificate has expired or is not up to date.

How to Fix the 'Peer Certificate Cannot be Authenticated with Given CA Certificates' Error

To fix the "Peer Certificate Cannot be Authenticated with Given CA Certificates" error, you need to add the CA's root certificate to your system's trusted CA store. Here are the steps to do this:

  1. Identify the CA that issued the server's certificate. You can usually find this information in the certificate's details, such as the Issuer field.
  2. Download the CA's root certificate from the CA's website or from a trusted source, such as the Mozilla CA Certificate Store.
  3. Add the CA's root certificate to your system's trusted CA store. The steps to do this vary depending on your operating system and browser. Here are the steps for some common operating systems:

Windows

  1. Open the Microsoft Management Console (MMC) by typing "mmc" in the Start menu search box and selecting "mmc.exe".
  2. Click "File" > "Add/Remove Snap-in".
  3. Select "Certificates" and click "Add".
  4. Select "Computer account" and click "Next".
  5. Select "Local computer" and click "Finish".
  6. Click "OK" to close the Add or Remove Snap-ins window.
  7. Expand "Certificates" > "Trusted Root Certification Authorities" and right-click "Certificates".
  8. Select "All Tasks" > "Import" and follow the wizard to import the CA's root certificate.

macOS

  1. Open the Keychain Access app by searching for it in Spotlight or launching it from the Utilities folder in the Applications folder.
  2. Click "File" > "Import Items".
  3. Select the CA's root certificate and click "Open".
  4. Enter your administrator password and click "Modify Keychain".
  5. In the Keychain Access app, select "System" in the "Keychains" list.
  6. Expand "Certificates" and verify that the CA's root certificate is listed.

Linux

  1. Copy the CA's root certificate to the /usr/local/share/ca-certificates/ directory.
  2. Run the following command: sudo update-ca-certificates

Frequently Asked Questions

Q1. What is a CA certificate?

A CA certificate is a digital certificate that is used to verify the authenticity of other digital certificates. It is issued by a trusted Certificate Authority (CA) and contains information about the CA's public key, name, and other identifying information.

Q2. Why is my system not trusting the server's certificate?

Your system may not trust the server's certificate for several reasons, such as the CA not being included in your system's trusted CA store, the server's certificate being self-signed or issued by an untrusted CA, or the CA's root certificate being expired or not up to date.

Q3. Can I add multiple CA certificates to my system's trusted CA store?

Yes, you can add multiple CA certificates to your system's trusted CA store. This is useful if you need to connect to multiple servers that use different CAs.

Q4. How do I verify that the CA's root certificate is installed correctly?

You can verify that the CA's root certificate is installed correctly by checking your system's trusted CA store or by using a tool like OpenSSL to connect to the server and verify its certificate.

Q5. What should I do if the server's certificate is still not trusted after adding the CA's root certificate?

If the server's certificate is still not trusted after adding the CA's root certificate, it may be because the server is using an outdated or revoked certificate. Contact the server administrator to resolve the issue.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Lxadm.com.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.