Software⏱️ 3 min read📅 2026-06-19

How to Fix: self signed certificate throwing "RSA_padding_check_PKCS1_type_1:invalid padding" error

RSA padding error in self-signed certificate

Quick Answer: The issue is caused by the RSA padding check failing due to invalid padding. To fix, use a different padding scheme or generate certificates with a valid padding scheme.

The RSA_padding_check_PKCS1_type_1:invalid padding error occurs when a self-signed certificate is not properly configured or formatted, causing issues with SSL/TLS connections. This error affects users who attempt to connect to servers using certificates that are not trusted by their systems.

This error can be frustrating for developers and administrators who need to troubleshoot SSL/TLS connectivity issues. Fortunately, there are steps you can take to resolve this issue and ensure secure connections to your server.

⚠️ Common Causes

  • The primary cause of the RSA_padding_check_PKCS1_type_1:invalid padding error is that the self-signed certificate contains invalid padding. This can occur when the certificate is generated using an insecure configuration or when the padding algorithm used in the certificate is not compatible with the system's trust store.
  • Another possible cause is that the certificate is not properly formatted or signed, which can lead to issues with SSL/TLS connections.

🚀 How to Resolve This Issue

Rehashing and Caching the Certificate

  1. Step 1: Run `openssl rehash` on the self-signed certificate to rehash it in a format compatible with most systems.
  2. Step 2: Copy the rehashed certificate to the `/etc/ssl/certs/` directory of your client machine.
  3. Step 3: Verify that the rehashed certificate is being used by running `curl --capath /etc/ssl/certs/ https://myserver.com/file.txt`.

Using a CA-Cert Bundle

  1. Step 1: Copy all certificates in the `/keys/` directory to the `/etc/ssl/certs/` directory of your client machine.
  2. Step 2: Run `curl --capath /etc/ssl/certs/ https://myserver.com/file.txt` to verify that the connection is successful.

💡 Conclusion

To resolve the RSA_padding_check_PKCS1_type_1:invalid padding error, try rehashing and caching your self-signed certificate or using a CA-cert bundle. By following these steps, you should be able to establish secure connections to your server.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions