Hi,
Using openid_authentication for authentication with keycloak for Opensearch and Opensearch-dashboards -
SSL is enabled for Keycloak server. Its server certificate is signed by a chain of certs like this →
(where Root CA is usually a self-signed well-known cert signing authority)
Certificate[1]:
Owner: CN=keycloak.io, C=IN
Issuer: CN=Signing CA2, OU=Example Com Inc. Signing CA, O=Example Com Inc., DC=example, DC=com
Certificate[2]:
Owner: CN=Signing CA2, OU=Example Com Inc. Signing CA, O=Example Com Inc., DC=example, DC=com
Issuer: CN=Signing CA1, OU=Example Com Inc. Signing CA, O=Example Com Inc., DC=example, DC=com
Certificate[3]:
Owner: CN=Signing CA1, OU=Example Com Inc. Signing CA, O=Example Com Inc., DC=example, DC=com
Issuer: CN=Root CA
Certificate[4]:
Owner: CN=Root CA
Issuer: CN=Root CA
Under opensearch and opensearch-dashboards openid configs, rootca of keycloak server is configured at -
pemtrustedcas_filepath
: under openid_auth_domain (for opensearch)
opensearch_security.openid.root_ca
: (for opensearch-dashboards)
Issue:
When we configure the complete chain of certs i.e #2, # 3 and #4 for keycloak rootca in opensearch and opensearch-dashboards , opensearch-dashboards works fine.
But when we configure only certs #2 and #3, opensearch-dashboards fails with this error in logs -
{"log":{"message":"{ Error: unable to get issuer certificate\n at TLSSocket.onConnectSecure (_tls_wrap.js:1088:34)\n at TLSSocket.emit (events.js:198:13)\n at TLSSocket._finishInit (_tls_wrap.js:666:8)\n code: 'UNABLE_TO_GET_ISSUER_CERT',\n trace:\n [ { method: 'GET',\n url:\n 'https://keycloak.io/access/realms/elk/.well-known/openid-configuration' } ],\n isBoom: true,\n isServer: true,\n data: null,\n output:\n { statusCode: 502,\n payload:\n { message: 'Client request error: unable to get issuer certificate',\n statusCode: 502,\n error: 'Bad Gateway' },\n headers: {} } }"},"extension":{"type":"log","tags":["error","plugins","opendistroSecurityKibana"],"pid":175},"type":"log","level":"info","timezone":"UTC","time":"2022-08-05T07:27:23Z"}
{"log":{"message":"Detected an unhandled Promise rejection.\nError: Failed when trying to obtain the endpoints from your IdP"},"extension":{"type":"log","tags":["warning","environment"],"pid":175},"type":"log","level":"info","timezone":"UTC","time":"2022-08-05T07:27:23Z"}
Whereas opensearch works fine i.e. if we issue a REST call to opensearch passing the authentication bearer token from keycloak, it works all fine.
#Fetch token from keycloak
curl --cacert /etc/keycloakRootCaPem --data "client_id=<clientid>&client_secret=<client-secret>&username=<user>&password=<[pwd>&grant_type=password" https://keycloak.io/access/realms/elk/protocol/openid-connect/token
# Using token in REST call
curl -k https://elasticsearch:9200/_cat/indices -H "Authorization: Bearer <obtained access token> "
Why is the behaviour such that - opensearch-dashboards needs the entire chain of certs in its truststore while opensearch does not need it and works fine with just immediate signing authorities?
Thanks!