Certificates do not conform to algorithm

Hedgelot 70 Reputation points
2023-04-06T11:54:46.88+00:00

I am trying to deploy an application that uses PostgreSQL as database. (The application is Keycloak). I have tried deploying it using Azure postgres single server and Azure postgres flexible server. I would prefer to deploy it using flexible server as it is newer, but unfortunatley I am getting an error when using flexible server. When using single server it is working fine. The error log is as follows:

ERROR: SSL error: Certificates do not conform to algorithm constraints
ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Certificates do not conform to algorithm constraints
ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Certificates do not conform to algorithm constraints
ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Algorithm constraints check failed on signature algorithm: SHA1withRSA

I found 2 links regarding this issue : https://stackoverflow.com/questions/75697268/keycloak-on-azure-to-postgresql-certificates-do-not-conform-to-algorithm-constr

https://github.com/keycloak/keycloak/issues/17320#issuecomment-1461573077

These links says it's due to the postgres database using the older SHA1 algorithm, some give a workaround but none of them seem to make Postgresql flexible server work with the newer algorithm. Can someone tell me how I can change the algorithm for postgres flexible server? I have tried appending &ssl_min_protocol_version=TLSv1.3 to the jdbc connection string, but it does not seem to work.
my connection string is: jdbc:postgresql://<postgresservername>.postgres.database.azure.com:5432/keycloak?sslmode=require&ssl_min_protocol_version=TLSv1.3

Azure Database for PostgreSQL
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,288 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Joe Madden 15 Reputation points
    2023-11-15T13:53:00.1066667+00:00

    @brtrach-MSFT

    Is there any updates for this? Sha 1 certitifcates have been deprecated since 2021 (https://video2.skills-academy.com/en-us/lifecycle/announcements/sha-1-signed-content-retired)

    Anything using Java 17 will not connect to a postgresql server using a sha1 certitifcate now.

    3 people found this answer helpful.
    0 comments No comments

  2. brtrach-MSFT 15,786 Reputation points Microsoft Employee
    2023-04-12T22:39:41.4433333+00:00

    @Hedgelot We understand that you are trying to use a newer algorithm with your Azure PostgreSQL flexible server but are encountering an error. We wanted to verify that the flexible server does indeed use the older SHA1 algorithm. At this time, there is not a way to update the algorithm to the newer SHA256 algorithm. The product group will need to make this change for customers. We invite you to create a feedback/product request over here on Azure Feedback to share your request and business justification so they can understand the ask. The product group watches the Azure Feedback site and should review your request. We appreciate your understanding.

    1 person found this answer helpful.

  3. Julian Gimbel 11 Reputation points Microsoft Employee
    2024-04-22T07:17:26.23+00:00

    There was an announcement via mail to the users of PostgreSQL Flexible that the certificate will be changed in May 2024 and the new cert "Microsoft RSA Root Certificate Authority 2017" uses sha384.

    https://www.microsoft.com/pkiops/certs/Microsoft%20RSA%20Root%20Certificate%20Authority%202017.crt

    Also there is a feedback in the Azure Community here:

    https://feedback.azure.com/d365community/idea/2cc1f0ed-1931-ee11-a81c-000d3ae37d1e

    Action Required for Azure Database for PostgreSQL – Flexible Server to update your trusted root store, if you are doing certificate pinning

    You're receiving this notice because you use Azure Database for PostgreSQL – Flexible Server

    In May 2024, we’ll begin updating Azure Database for PostgreSQL Flexible Server to use TLS certificates from Microsoft RSA Root Certificate Authority 2017. If your apps use certificate pinning, you’ll need to update your trusted root store to accept this root CA in addition to existing  DigiCert Global Root CA.

    • If your applications take advantage of verify-ca or verify-full as value of sslmode parameter in the database client connectivity they may be affected by this change and need to follow below directions to add new certificates to certificate store to maintain connectivity.
    • If your connection string includes sslmode=disable, sslmode=allow, sslmode=prefer, or sslmode=require, you don’t need to update certificates. If you’re using a client that abstracts the connection string away, review the client's documentation to understand whether it verifies certificates. To understand PostgreSQL sslmode, review the SSL mode descriptions in PostgreSQL documentation.

    Required action

    Please download Microsoft RSA Root Certificate Authority 2017 and DigiCert Global Root CA certificates from the following URI. Generate a combined CA certificate store with both DigiCert Global Root CA and Microsoft RSA Root Certificate Authority 2017 certificates are included. For Java (PostgreSQL JDBC) users using DefaultJavaSSLFactory, please use the following certificate:

    • keytool -importcert -alias PostgreSQLServerCACert -DigiCertGlobalRootCA.crt.pem -keystore truststore -storepass password -noprompt

    keytool -importcert -alias PostgreSQLServerCACert2 -file D:\ Microsoft ECC Root Certificate Authority 2017.crt.pem -keystore truststore -storepass password -noprompt

    Then replace the original keystore file with the new generated one:

    • System.setProperty("javax.net.ssl.trustStore","path_to_truststore_file");

    System.setProperty("javax.net.ssl.trustStorePassword","password");

    For .NET (Npgsql) users on Windows, make sure DigiCert Global Root CA and Microsoft RSA Root Certificate Authority 2017 both exist in Windows Certificate Store Trusted Root Certification Authorities. For .NET (Npgsql) users on Linux using SSL_CERT_DIR, make sure DigiCert Global Root CA and Microsoft RSA Root Certificate Authority 2017 both exist in the directory indicated by SSL_CERT_DIR. If any certificates don't exist, please create the missing certificate file. For other PostgreSQL client users, you can merge two CA certificate files like the following format:

    • -----BEGIN CERTIFICATE-----

    (Root CA1: DigiCertGlobalRootCA.crt.pem)

    -----END CERTIFICATE-----

    -----BEGIN CERTIFICATE-----

    (Root CA2: Microsoft ECC Root Certificate Authority 2017.crt.pem)

    -----END CERTIFICATE-----

    Replace the original root CA pem file with the combined root CA file and restart your application/client. 

    If you’re using SSL/TLS, you don't need to restart the database server to start using the new root CA certificate. This is a client-side change, and the incoming client connections need to use the new certificate to ensure that they can connect to the database server. If you aren’t using SSL/TLS, you don’t need to update the root CA certificate and no further action is required. Action Required for Azure Database for PostgreSQL – Flexible Server to update your trusted root store, if you are doing certificate pinning

    You're receiving this notice because you use Azure Database for PostgreSQL – Flexible Server

    In May 2024, we’ll begin updating Azure Database for PostgreSQL Flexible Server to use TLS certificates from Microsoft RSA Root Certificate Authority 2017. If your apps use certificate pinning, you’ll need to update your trusted root store to accept this root CA in addition to existing  DigiCert Global Root CA.

    • If your applications take advantage of verify-ca or verify-full as value of sslmode parameter in the database client connectivity they may be affected by this change and need to follow below directions to add new certificates to certificate store to maintain connectivity.
    • If your connection string includes sslmode=disable, sslmode=allow, sslmode=prefer, or sslmode=require, you don’t need to update certificates. If you’re using a client that abstracts the connection string away, review the client's documentation to understand whether it verifies certificates. To understand PostgreSQL sslmode, review the SSL mode descriptions in PostgreSQL documentation.

    Required action

    Please download Microsoft RSA Root Certificate Authority 2017 and DigiCert Global Root CA certificates from the following URI. Generate a combined CA certificate store with both DigiCert Global Root CA and Microsoft RSA Root Certificate Authority 2017 certificates are included. For Java (PostgreSQL JDBC) users using DefaultJavaSSLFactory, please use the following certificate:

    • keytool -importcert -alias PostgreSQLServerCACert -DigiCertGlobalRootCA.crt.pem -keystore truststore -storepass password -noprompt keytool -importcert -alias PostgreSQLServerCACert2 -file D:\ Microsoft ECC Root Certificate Authority 2017.crt.pem -keystore truststore -storepass password -noprompt

    Then replace the original keystore file with the new generated one:

    • System.setProperty("javax.net.ssl.trustStore","path_to_truststore_file");

    System.setProperty("javax.net.ssl.trustStorePassword","password");

    For .NET (Npgsql) users on Windows, make sure DigiCert Global Root CA and Microsoft RSA Root Certificate Authority 2017 both exist in Windows Certificate Store Trusted Root Certification Authorities. For .NET (Npgsql) users on Linux using SSL_CERT_DIR, make sure DigiCert Global Root CA and Microsoft RSA Root Certificate Authority 2017 both exist in the directory indicated by SSL_CERT_DIR. If any certificates don't exist, please create the missing certificate file. For other PostgreSQL client users, you can merge two CA certificate files like the following format:

    • -----BEGIN CERTIFICATE-----

    (Root CA1: DigiCertGlobalRootCA.crt.pem)

    -----END CERTIFICATE-----

    -----BEGIN CERTIFICATE-----

    (Root CA2: Microsoft ECC Root Certificate Authority 2017.crt.pem)

    -----END CERTIFICATE-----

    Replace the original root CA pem file with the combined root CA file and restart your application/client. 

    If you’re using SSL/TLS, you don't need to restart the database server to start using the new root CA certificate. This is a client-side change, and the incoming client connections need to use the new certificate to ensure that they can connect to the database server. If you aren’t using SSL/TLS, you don’t need to update the root CA certificate and no further action is required.

    1 person found this answer helpful.
    0 comments No comments