OpenID 401 after node restart

OpenSearch 2.9, OpenSearch Dashboards 2.9 running in docker

After a node restarts, Dashboards will give 401 after openid login.

Dashboards logs:

{"type":"log","@timestamp":"2023-09-13T12:52:41Z","tags":["error","plugins","securityDashboards"],"pid":1,"message":"OpenId authentication failed: Error: Authentication Exception"}
{"type":"response","@timestamp":"2023-09-13T12:52:40Z","tags":[],"pid":1,"method":"get","statusCode":401,"req":{"url":"/auth/openid/login?state=YFYM25e6siG4CkZixoZ0p3&session_state=2782af0b-5ea5-49f2-aeb4-2049d79e1fc5&code=58803566-f2fb-4432-b36e-66dea4fe0671.2782af0b-5ea5-49f2-aeb4-2049d79e1fc5.d021f693-b83c-45bf-aeaf-f7f624b96564","method":"get","headers":{"host":"dashboard:5669","user-agent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate, br","connection":"keep-alive","upgrade-insecure-requests":"1","sec-fetch-dest":"document","sec-fetch-mode":"navigate","sec-fetch-site":"none","sec-fetch-user":"?1"},"remoteAddress":"100.79.242.11","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"},"res":{"statusCode":401,"responseTime":172,"contentLength":9},"message":"GET /auth/openid/login?state=YFYM25e6siG4CkZixoZ0p3&session_state=2782af0b-5ea5-49f2-aeb4-2049d79e1fc5&code=58803566-f2fb-4432-b36e-66dea4fe0671.2782af0b-5ea5-49f2-aeb4-2049d79e1fc5.d021f693-b83c-45bf-aeaf-f7f624b96564 401 172ms - 9.0B"}
{"type":"log","@timestamp":"2023-09-13T12:53:12Z","tags":["error","plugins","securityDashboards"],"pid":1,"message":"OpenId authentication failed: Error: Response Error: 400 Bad Request"}
{"type":"response","@timestamp":"2023-09-13T12:53:12Z","tags":[],"pid":1,"method":"get","statusCode":302,"req":{"url":"/auth/openid/login?state=YFYM25e6siG4CkZixoZ0p3&session_state=2782af0b-5ea5-49f2-aeb4-2049d79e1fc5&code=58803566-f2fb-4432-b36e-66dea4fe0671.2782af0b-5ea5-49f2-aeb4-2049d79e1fc5.d021f693-b83c-45bf-aeaf-f7f624b96564","method":"get","headers":{"host":"dashboard:5669","user-agent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate, br","connection":"keep-alive","upgrade-insecure-requests":"1","sec-fetch-dest":"document","sec-fetch-mode":"navigate","sec-fetch-site":"same-site"},"remoteAddress":"100.79.242.11","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"},"res":{"statusCode":302,"responseTime":77,"contentLength":9},"message":"GET /auth/openid/login?state=YFYM25e6siG4CkZixoZ0p3&session_state=2782af0b-5ea5-49f2-aeb4-2049d79e1fc5&code=58803566-f2fb-4432-b36e-66dea4fe0671.2782af0b-5ea5-49f2-aeb4-2049d79e1fc5.d021f693-b83c-45bf-aeaf-f7f624b96564 302 77ms - 9.0B"}
{"type":"response","@timestamp":"2023-09-13T12:53:12Z","tags":[],"pid":1,"method":"get","statusCode":302,"req":{"url":"/auth/openid/login","method":"get","headers":{"host":"dashboard:5669","user-agent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate, br","connection":"keep-alive","upgrade-insecure-requests":"1","sec-fetch-dest":"document","sec-fetch-mode":"navigate","sec-fetch-site":"same-site"},"remoteAddress":"100.79.242.11","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"},"res":{"statusCode":302,"responseTime":5,"contentLength":9},"message":"GET /auth/openid/login 302 5ms - 9.0B"}
{"type":"log","@timestamp":"2023-09-13T12:53:12Z","tags":["error","plugins","securityDashboards"],"pid":1,"message":"OpenId authentication failed: Error: Authentication Exception"}
{"type":"response","@timestamp":"2023-09-13T12:53:12Z","tags":[],"pid":1,"method":"get","statusCode":401,"req":{"url":"/auth/openid/login?state=JtVkx9Z0KGsm1D_BDZ1L3x&session_state=2782af0b-5ea5-49f2-aeb4-2049d79e1fc5&code=5bebb3e1-525b-4916-a3d4-28ed6c5cdff7.2782af0b-5ea5-49f2-aeb4-2049d79e1fc5.d021f693-b83c-45bf-aeaf-f7f624b96564","method":"get","headers":{"host":"dashboard:5669","user-agent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate, br","connection":"keep-alive","upgrade-insecure-requests":"1","sec-fetch-dest":"document","sec-fetch-mode":"navigate","sec-fetch-site":"same-site"},"remoteAddress":"100.79.242.11","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"},"res":{"statusCode":401,"responseTime":55,"contentLength":9},"message":"GET /auth/openid/login?state=JtVkx9Z0KGsm1D_BDZ1L3x&session_state=2782af0b-5ea5-49f2-aeb4-2049d79e1fc5&code=5bebb3e1-525b-4916-a3d4-28ed6c5cdff7.2782af0b-5ea5-49f2-aeb4-2049d79e1fc5.d021f693-b83c-45bf-aeaf-f7f624b96564 401 55ms - 9.0B"}

In OpenSearch logs I see errors related to openid_connect_idp.pemkey_filepath and pemcert_filepath:

Caused by: java.lang.RuntimeException: com.amazon.dlic.util.SettingsBasedSSLConfigurator$SSLConfigException: Error loading PEM from /usr/share/opensearch/config/certificates/auth-client.key (openid_connect_idp.pemkey_filepath) for openid_connect_idp.
	at com.amazon.dlic.auth.http.jwt.AbstractHTTPJwtAuthenticator.<init>(AbstractHTTPJwtAuthenticator.java:80) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.<init>(HTTPJwtKeyByOpenIdConnectAuthenticator.java:26) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
	at org.opensearch.security.support.ReflectionHelper.instantiateAAA(ReflectionHelper.java:62) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	... 25 more
Caused by: com.amazon.dlic.util.SettingsBasedSSLConfigurator$SSLConfigException: Error loading PEM from /usr/share/opensearch/config/certificates/auth-client.key (openid_connect_idp.pemkey_filepath) for openid_connect_idp.
	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.initFromPem(SettingsBasedSSLConfigurator.java:296) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.configureWithSettings(SettingsBasedSSLConfigurator.java:192) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.buildSSLContext(SettingsBasedSSLConfigurator.java:115) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.buildSSLConfig(SettingsBasedSSLConfigurator.java:129) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.getSSLConfig(HTTPJwtKeyByOpenIdConnectAuthenticator.java:65) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.initKeyProvider(HTTPJwtKeyByOpenIdConnectAuthenticator.java:47) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.auth.http.jwt.AbstractHTTPJwtAuthenticator.<init>(AbstractHTTPJwtAuthenticator.java:75) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.<init>(HTTPJwtKeyByOpenIdConnectAuthenticator.java:26) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
	at org.opensearch.security.support.ReflectionHelper.instantiateAAA(ReflectionHelper.java:62) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	... 25 more
Caused by: java.security.AccessControlException: access denied ("java.security.SecurityPermission" "removeProviderProperty.BC")
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:485) ~[?:?]
	at java.security.AccessController.checkPermission(AccessController.java:1068) ~[?:?]
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:416) ~[?:?]
	at java.lang.SecurityManager.checkSecurityAccess(SecurityManager.java:1531) ~[?:?]
	at java.security.Provider.check(Provider.java:816) ~[?:?]
	at java.security.Provider.remove(Provider.java:523) ~[?:?]
	at org.bouncycastle.jce.provider.BouncyCastleProvider.getService(Unknown Source) ~[bcprov-jdk15to18-1.75.jar:1.75.0.0]
	at sun.security.jca.ProviderList$ServiceList.tryGet(ProviderList.java:518) ~[?:?]
	at sun.security.jca.ProviderList$ServiceList$1.hasNext(ProviderList.java:567) ~[?:?]
	at java.security.KeyFactory.nextSpi(KeyFactory.java:312) ~[?:?]
	at java.security.KeyFactory.generatePrivate(KeyFactory.java:394) ~[?:?]
	at org.opensearch.security.support.PemKeyReader.getPrivateKeyFromByteBuffer(PemKeyReader.java:128) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at org.opensearch.security.support.PemKeyReader.toPrivateKey(PemKeyReader.java:109) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at org.opensearch.security.support.PemKeyReader.loadKeyFromFile(PemKeyReader.java:197) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.initFromPem(SettingsBasedSSLConfigurator.java:294) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.configureWithSettings(SettingsBasedSSLConfigurator.java:192) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.buildSSLContext(SettingsBasedSSLConfigurator.java:115) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.buildSSLConfig(SettingsBasedSSLConfigurator.java:129) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.getSSLConfig(HTTPJwtKeyByOpenIdConnectAuthenticator.java:65) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.initKeyProvider(HTTPJwtKeyByOpenIdConnectAuthenticator.java:47) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.auth.http.jwt.AbstractHTTPJwtAuthenticator.<init>(AbstractHTTPJwtAuthenticator.java:75) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.<init>(HTTPJwtKeyByOpenIdConnectAuthenticator.java:26) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
	at org.opensearch.security.support.ReflectionHelper.instantiateAAA(ReflectionHelper.java:62) ~[opensearch-security-2.9.0.0.jar:2.9.0.0]
	... 25 more

The file permissions should be correct, the owner is opensearch, and I executed chmod 600 on them, as the opensearch warning logs suggested at startup.

What’s weird is if I uncomment the pemcert_filepath, and pemkey_filepath settings on one OpenSearch node (there is 3 in the cluster) in the security config, then run securityadmin.sh on that node, the issue goese away and I can log in, until one of the nodes restarts again.

If I put the settings back after the previous step and rerun securityadmin.sh there is no issue. If I leave them commented and then a node restarts, then the problem appears again, but I can fix it by putting the settings back and running securityadmin.sh again.

Simply running securityadmin.sh never helps. The pemcert_filepath and pemkey_filepath settings need to be changed (commented out/put back) in the config file. Weird behaviour.

Configuration:

_meta:
  type: "config"
  config_version: 2
config:
  dynamic:
    authc:
      basic_internal_auth_domain:
        http_enabled: true
        transport_enabled: true
        order: 0
        http_authenticator:
          type: basic
          challenge: false
        authentication_backend:
          type: internal
      openid_auth_domain:
        http_enabled: true
        transport_enabled: true
        order: 1
        http_authenticator:
          type: openid
          challenge: false
          config:
            openid_connect_idp:
              enable_ssl: true
              verify_hostnames: true
              pemtrustedcas_filepath: /usr/share/opensearch/config/certificates/server-ca.crt
              pemcert_filepath: /usr/share/opensearch/config/certificates/auth-client.pem
              pemkey_filepath: /usr/share/opensearch/config/certificates/auth-client.key
              enable_ssl_client_auth: true
            subject_key: preferred_username
            roles_key: roles
            openid_connect_url: https://keycloak-url/auth/realms/asdf/.well-known/openid-configuration
        authentication_backend:
          type: noop

Hi @szurokl,

Could you please run the below when your cluster is working as expected (after a reboot of one node as well if possible), and share the outcome for "authc"."openid_auth_domain"?

curl --insecure -u [adminUsername]:[adminPassword] -XGET https://<OpenSearch_node_FQDN_or_IP>:9200/_plugins/_security/api/securityconfig?pretty

Note: Ensure all sensitive information is removed/masked before sharing any data.

Thanks,
Mantas

Hi @Mantas !
Here is the requested part of the outcome of the above API call, when the cluster is working correctly:

      "authc" : {
        "openid_auth_domain" : {
          "http_enabled" : true,
          "transport_enabled" : true,
          "order" : 1,
          "http_authenticator" : {
            "challenge" : false,
            "type" : "openid",
            "config" : {
              "openid_connect_idp" : {
                "enable_ssl" : true,
                "verify_hostnames" : true,
                "pemtrustedcas_filepath" : "/usr/share/opensearch/config/certificates/server-ca.crt",
                "pemcert_filepath" : "/usr/share/opensearch/config/certificates/auth-client.pem",
                "pemkey_filepath" : "/usr/share/opensearch/config/certificates/auth-client.key",
                "enable_ssl_client_auth" : true
              },
              "subject_key" : "preferred_username",
              "roles_key" : "roles",
              "openid_connect_url" : "https://keycloak-url/auth/realms/myrealm/.well-known/openid-configuration"
            }
          },
          "authentication_backend" : {
            "type" : "noop",
            "config" : { }
          }
        },
        "basic_internal_auth_domain" : {
          "http_enabled" : true,
          "transport_enabled" : true,
          "order" : 0,
          "http_authenticator" : {
            "challenge" : false,
            "type" : "basic",
            "config" : { }
          },
          "authentication_backend" : {
            "type" : "internal",
            "config" : { }
          }
        }
      },

I wrote this lengthy list as I executed each step. Excuse my typos/incorrect grammar, I tried to only type out what’s important. So the exact steps I executed after the above API call:

  1. I logged out of Ops. Dashboards
  2. I stopped one OpenSearch node (out of 3)
  3. I checked if I can log in to Dashboards at this point. I was able to log in successfully.
  4. I logged out again.
  5. I started the node.
  6. Tried logging in immediately after start and I successfully logged in, but then got a status code 500 on Dashboards when the node fully booted. I reloaded the page and got the 401 status code.
  7. I run your API call again. I diffed it with the first one and there is no difference in openid_auth_domain (only one line differed: internalProxies, which is not under the authc key)
  8. I checked OpenSearch logs, you can see them below.
  9. Tried running securityadmin, still 401
  10. Uncommented pemcert_filepath and pemkey_filepath in security config file of the same node, then rerun securityadmin.
  11. Successful login on Dashboards.
  12. Put configs back, rerun script, still successful login.
  13. I restarted the same node again because I wanted to closely watch the opensearch logs at startaup. After restart I tried to log in to Dashboards. After I enterd the credentials into the keycloak login UI and pressed enter, I got a popup, asking for credentials. I entered same creds into the popup and it let me in :rofl: At this point I’m unable to log out. When I try to log out I get the following message from keycloak: invalid parameter: id_token_hint. Never before I’ve seen this popup or this keycloak message. I checked the opensearch logs, but did not see more info.
  14. I rerun securityadmin. No change from step 13.
  15. Comment out the above mentioned configs again and rerun script. Still no change from step 13.
  16. Put configs back, restart node. Still step 13.
  17. Comment configs out → script → still sterp 13.
  18. Put configs back → script → still setp 13.
  19. Sighs No idea whats going on.

OpenSearch logs from step 8:

Disabling execution of install_demo_configuration.sh for OpenSearch Security Plugin
Enabling OpenSearch Security Plugin
Enabling execution of OPENSEARCH_HOME/bin/opensearch-performance-analyzer/performance-analyzer-agent-cli for OpenSearch Performance Analyzer Plugin
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.opensearch.bootstrap.OpenSearch (file:/usr/share/opensearch/lib/opensearch-2.9.0.jar)
WARNING: Please consider reporting this to the maintainers of org.opensearch.bootstrap.OpenSearch
WARNING: System::setSecurityManager will be removed in a future release
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.opensearch.bootstrap.Security (file:/usr/share/opensearch/lib/opensearch-2.9.0.jar)
WARNING: Please consider reporting this to the maintainers of org.opensearch.bootstrap.Security
WARNING: System::setSecurityManager will be removed in a future release
[2023-09-15T14:12:21,479][WARN ][o.o.s.OpenSearchSecurityPlugin] [node1] Directory /usr/share/opensearch/config has insecure file permissions (should be 0700)
[2023-09-15T14:12:21,482][WARN ][o.o.s.OpenSearchSecurityPlugin] [node1] File /usr/share/opensearch/config/log4j2.properties has insecure file permissions (should be 0600)
[2023-09-15T14:12:21,482][WARN ][o.o.s.OpenSearchSecurityPlugin] [node1] File /usr/share/opensearch/config/certificates/server-ca.crt has insecure file permissions (should be 0600)
[2023-09-15T14:12:27,556][WARN ][o.o.s.c.Salt             ] [node1] If you plan to use field masking pls configure compliance salt e1ukloTsQlOgPquJ to be a random string of 16 chars length identical on all nodes
[2023-09-15T14:12:27,599][ERROR][o.o.s.a.s.SinkProvider   ] [node1] Default endpoint could not be created, auditlog will not work properly.
[2023-09-15T14:12:27,600][WARN ][o.o.s.a.r.AuditMessageRouter] [node1] No default storage available, audit log may not work properly. Please check configuration.
[2023-09-15T14:12:28,737][WARN ][o.o.s.p.SQLPlugin        ] [node1] Master key is a required config for using create and update datasource APIs. Please set plugins.query.datasources.encryption.masterkey config in opensearch.yml in all the cluster nodes. More details can be found here: https://github.com/opensearch-project/sql/blob/main/docs/user/ppl/admin/datasources.rst#master-key-config-for-encrypting-credential-information
[2023-09-15T14:12:29,999][WARN ][o.o.g.DanglingIndicesState] [node1] gateway.auto_import_dangling_indices is disabled, dangling indices will not be automatically detected or imported and must be managed manually
[2023-09-15T14:12:35,386][WARN ][o.o.p.c.s.h.ConfigOverridesClusterSettingHandler] [node1] Config override setting update called with empty string. Ignoring.
[2023-09-15T14:12:35,465][ERROR][o.o.s.a.BackendRegistry  ] [node1] Not yet initialized (you may need to run securityadmin)
[2023-09-15T14:12:35,470][ERROR][o.o.s.a.BackendRegistry  ] [node1] Not yet initialized (you may need to run securityadmin)
[2023-09-15T14:12:35,752][ERROR][c.a.d.a.h.j.AbstractHTTPJwtAuthenticator] [node1] Error creating JWT authenticator. JWT authentication will not work com.amazon.dlic.util.SettingsBasedSSLConfigurator$SSLConfigException: Error loading PEM from /usr/share/opensearch/config/certificates/auth-client.key (openid_connect_idp.pemkey_filepath) for openid_connect_idp. 	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.initFromPem(SettingsBasedSSLConfigurator.java:296) 	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.configureWithSettings(SettingsBasedSSLConfigurator.java:192) 	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.buildSSLContext(SettingsBasedSSLConfigurator.java:115) 	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.buildSSLConfig(SettingsBasedSSLConfigurator.java:129) 	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.getSSLConfig(HTTPJwtKeyByOpenIdConnectAuthenticator.java:65) 	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.initKeyProvider(HTTPJwtKeyByOpenIdConnectAuthenticator.java:47) 	at com.amazon.dlic.auth.http.jwt.AbstractHTTPJwtAuthenticator.<init>(AbstractHTTPJwtAuthenticator.java:75) 	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.<init>(HTTPJwtKeyByOpenIdConnectAuthenticator.java:26) 	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) 	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) 	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) 	at org.opensearch.security.support.ReflectionHelper.instantiateAAA(ReflectionHelper.java:62) 	at org.opensearch.security.securityconf.DynamicConfigModelV7.newInstance(DynamicConfigModelV7.java:406) 	at org.opensearch.security.securityconf.DynamicConfigModelV7.buildAAA(DynamicConfigModelV7.java:310) 	at org.opensearch.security.securityconf.DynamicConfigModelV7.<init>(DynamicConfigModelV7.java:87) 	at org.opensearch.security.securityconf.DynamicConfigFactory.onChange(DynamicConfigFactory.java:283) 	at org.opensearch.security.configuration.ConfigurationRepository.notifyAboutChanges(ConfigurationRepository.java:406) 	at org.opensearch.security.configuration.ConfigurationRepository.reloadConfiguration0(ConfigurationRepository.java:395) 	at org.opensearch.security.configuration.ConfigurationRepository.reloadConfiguration(ConfigurationRepository.java:379) 	at org.opensearch.security.configuration.ConfigurationRepository.lambda$new$0(ConfigurationRepository.java:221) 	at java.base/java.lang.Thread.run(Thread.java:833) Caused by: java.security.AccessControlException: access denied ("java.security.SecurityPermission" "removeProviderProperty.BC") 	at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:485) 	at java.base/java.security.AccessController.checkPermission(AccessController.java:1068) 	at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:416) 	at java.base/java.lang.SecurityManager.checkSecurityAccess(SecurityManager.java:1531) 	at java.base/java.security.Provider.check(Provider.java:816) 	at java.base/java.security.Provider.remove(Provider.java:523) 	at org.bouncycastle.jce.provider.BouncyCastleProvider.getService(Unknown Source) 	at java.base/sun.security.jca.ProviderList$ServiceList.tryGet(ProviderList.java:518) 	at java.base/sun.security.jca.ProviderList$ServiceList$1.hasNext(ProviderList.java:567) 	at java.base/java.security.KeyFactory.nextSpi(KeyFactory.java:312) 	at java.base/java.security.KeyFactory.generatePrivate(KeyFactory.java:394) 	at org.opensearch.security.support.PemKeyReader.getPrivateKeyFromByteBuffer(PemKeyReader.java:125) 	at org.opensearch.security.support.PemKeyReader.toPrivateKey(PemKeyReader.java:109) 	at org.opensearch.security.support.PemKeyReader.loadKeyFromFile(PemKeyReader.java:197) 	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.initFromPem(SettingsBasedSSLConfigurator.java:294) 	... 22 more
[2023-09-15T14:12:35,754][WARN ][o.o.s.s.ReflectionHelper ] [node1] Unable to enable 'com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator' due to java.lang.reflect.InvocationTargetException
[2023-09-15T14:12:35,783][ERROR][o.o.s.s.DynamicConfigModelV7] [node1] Unable to initialize auth domain openid_auth_domain=AuthcDomain [http_enabled=true, transport_enabled=true, order=1, http_authenticator=HttpAuthenticator [challenge=false, type=openid, config={openid_connect_idp={enable_ssl=true, verify_hostnames=true, pemtrustedcas_filepath=/usr/share/opensearch/config/certificates/server-ca.crt, pemcert_filepath=/usr/share/opensearch/config/certificates/auth-client.pem, pemkey_filepath=/usr/share/opensearch/config/certificates/auth-client.key, enable_ssl_client_auth=true}, subject_key=preferred_username, roles_key=roles, openid_connect_url=https://keycloak-url/auth/realms/myrealm/.well-known/openid-configuration}], authentication_backend=AuthcBackend [type=noop, config={}], description=null] due to OpenSearchException[java.lang.reflect.InvocationTargetException]; nested: InvocationTargetException; nested: RuntimeException[com.amazon.dlic.util.SettingsBasedSSLConfigurator$SSLConfigException: Error loading PEM from /usr/share/opensearch/config/certificates/auth-client.key (openid_connect_idp.pemkey_filepath) for openid_connect_idp.]; nested: SSLConfigException[Error loading PEM from /usr/share/opensearch/config/certificates/auth-client.key (openid_connect_idp.pemkey_filepath) for openid_connect_idp.]; nested: AccessControlException[access denied ("java.security.SecurityPermission" "removeProviderProperty.BC")]; OpenSearchException[java.lang.reflect.InvocationTargetException]; nested: InvocationTargetException; nested: RuntimeException[com.amazon.dlic.util.SettingsBasedSSLConfigurator$SSLConfigException: Error loading PEM from /usr/share/opensearch/config/certificates/auth-client.key (openid_connect_idp.pemkey_filepath) for openid_connect_idp.]; nested: SSLConfigException[Error loading PEM from /usr/share/opensearch/config/certificates/auth-client.key (openid_connect_idp.pemkey_filepath) for openid_connect_idp.]; nested: AccessControlException[access denied ("java.security.SecurityPermission" "removeProviderProperty.BC")]; 	at org.opensearch.security.support.ReflectionHelper.instantiateAAA(ReflectionHelper.java:73) 	at org.opensearch.security.securityconf.DynamicConfigModelV7.newInstance(DynamicConfigModelV7.java:406) 	at org.opensearch.security.securityconf.DynamicConfigModelV7.buildAAA(DynamicConfigModelV7.java:310) 	at org.opensearch.security.securityconf.DynamicConfigModelV7.<init>(DynamicConfigModelV7.java:87) 	at org.opensearch.security.securityconf.DynamicConfigFactory.onChange(DynamicConfigFactory.java:283) 	at org.opensearch.security.configuration.ConfigurationRepository.notifyAboutChanges(ConfigurationRepository.java:406) 	at org.opensearch.security.configuration.ConfigurationRepository.reloadConfiguration0(ConfigurationRepository.java:395) 	at org.opensearch.security.configuration.ConfigurationRepository.reloadConfiguration(ConfigurationRepository.java:379) 	at org.opensearch.security.configuration.ConfigurationRepository.lambda$new$0(ConfigurationRepository.java:221) 	at java.base/java.lang.Thread.run(Thread.java:833) Caused by: java.lang.reflect.InvocationTargetException 	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) 	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) 	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) 	at org.opensearch.security.support.ReflectionHelper.instantiateAAA(ReflectionHelper.java:62) 	... 9 more Caused by: java.lang.RuntimeException: com.amazon.dlic.util.SettingsBasedSSLConfigurator$SSLConfigException: Error loading PEM from /usr/share/opensearch/config/certificates/auth-client.key (openid_connect_idp.pemkey_filepath) for openid_connect_idp. 	at com.amazon.dlic.auth.http.jwt.AbstractHTTPJwtAuthenticator.<init>(AbstractHTTPJwtAuthenticator.java:80) 	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.<init>(HTTPJwtKeyByOpenIdConnectAuthenticator.java:26) 	... 15 more Caused by: com.amazon.dlic.util.SettingsBasedSSLConfigurator$SSLConfigException: Error loading PEM from /usr/share/opensearch/config/certificates/auth-client.key (openid_connect_idp.pemkey_filepath) for openid_connect_idp. 	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.initFromPem(SettingsBasedSSLConfigurator.java:296) 	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.configureWithSettings(SettingsBasedSSLConfigurator.java:192) 	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.buildSSLContext(SettingsBasedSSLConfigurator.java:115) 	at com.amazon.dlic.util.SettingsBasedSSLConfigurator.buildSSLConfig(SettingsBasedSSLConfigurator.java:129) 	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.getSSLConfig(HTTPJwtKeyByOpenIdConnectAuthenticator.java:65) 	at com.amazon.dlic.auth.http.jwt.keybyoidc.HTTPJwtKeyByOpenIdConnectAuthenticator.initKeyProvider(HTTPJwtKeyByOpenIdConnectAuthenticator.java:47) 	at com.amazon.dlic.auth.http.jwt.AbstractHTTPJwtAuthenticator.<init>(AbstractHTTPJwtAuthenticator.java:75) 	... 16 more Caused by: java.security.AccessControlException: access denied ("java.security.SecurityPermission" "removeProviderProperty.BC") 	at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:485) 	at java.base/java.security.AccessController.checkPermission(AccessController.java:1068) 	at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:416) 	at java.base/java.lang.SecurityManager.checkSecurityAccess(SecurityManager.java:1531) 	at java.base/java.security.Provider.check(Provider.java:816) 	at java.base/java.security.Provider.remove(Provider.java:523) 	at org.bouncycastle.jce.provider.BouncyCastleProvider.getService(Unknown Source) 	at java.base/sun.security.jca.ProviderList$ServiceList.tryGet(ProviderList.java:518) 	at java.base/sun.security.jca.ProviderList$ServiceList$1.hasNext(ProviderList.java:567) 	at java.base/java.security.KeyFactory.nextSpi(KeyFactory.java:312) 	at java.base/java.security.KeyFactory.generatePrivate(KeyFactory.java:394) 	at org.opensearch.security.support.PemKeyReader.getPrivateKeyFromByteBuffer(PemKeyReader.java:125) 	at org.opensearch.security.support.PemKeyReader.toPrivateKey(PemKeyReader.java:109) 	at org.opensearch.security.support.PemKeyReader.loadKeyFromFile(PemKeyReader.java:197) at com.amazon.dlic.util.SettingsBasedSSLConfigurator.initFromPem(SettingsBasedSSLConfigurator.java:294) 	... 22 more
[2023-09-15T14:12:56,760][WARN ][o.o.s.a.BackendRegistry  ] [node1] Authentication finally failed for null from 192.168.192.1:42230
[2023-09-15T14:12:59,071][WARN ][o.o.s.a.BackendRegistry  ] [node1] Authentication finally failed for null from 192.168.192.1:42234
[2023-09-15T14:13:03,652][WARN ][o.o.s.h.HTTPBasicAuthenticator] [node1] No 'Basic Authorization' header, send 401 and 'WWW-Authenticate Basic'
[2023-09-15T14:13:03,652][WARN ][o.o.s.a.BackendRegistry  ] [node1] Authentication finally failed for null from 192.168.192.1:42230
[2023-09-15T14:13:10,881][WARN ][o.o.s.a.BackendRegistry  ] [node1] Authentication finally failed for null from 100.79.242.18:55994
[2023-09-15T14:13:12,196][WARN ][o.o.s.h.HTTPBasicAuthenticator] [node1] No 'Basic Authorization' header, send 401 and 'WWW-Authenticate Basic'
[2023-09-15T14:13:12,196][WARN ][o.o.s.a.BackendRegistry  ] [node1] Authentication finally failed for null from 192.168.192.1:42230
[2023-09-15T14:13:18,119][WARN ][o.o.s.a.BackendRegistry  ] [node1] Authentication finally failed for null from 100.79.242.22:47526
[2023-09-15T14:16:46,712][ERROR][o.o.s.s.h.n.SecuritySSLNettyHttpServerTransport] [node1] Exception during establishing a SSL connection: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131) 	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:378) 	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321) 	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:316) 	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkClientCerts(CertificateMessage.java:1301) 	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1204) 	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1181) 	at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396) 	at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480) 	at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1277) 	at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1264) 	at java.base/java.security.AccessController.doPrivileged(AccessController.java:712) 	at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask.run(SSLEngineImpl.java:1209) 	at io.netty.handler.ssl.SslHandler.runDelegatedTasks(SslHandler.java:1559) 	at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1405) 	at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1246) 	at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1295) 	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529) 	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468) 	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290) 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) 	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) 	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) 	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) 	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) 	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) 	at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:689) 	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:652) 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) 	at java.base/java.lang.Thread.run(Thread.java:833) Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 	at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:439) 	at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:306) 	at java.base/sun.security.validator.Validator.validate(Validator.java:264) 	at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:285) 	at java.base/sun.security.ssl.X509TrustManagerImpl.checkClientTrusted(X509TrustManagerImpl.java:138) 	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkClientCerts(CertificateMessage.java:1279) 	... 30 more Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 	at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:146) 	at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:127) 	at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297) 	at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434) 	... 35 more
[2023-09-15T14:16:46,718][WARN ][o.o.h.AbstractHttpServerTransport] [node1] caught exception while handling client http traffic, closing connection Netty4HttpChannel{localAddress=/192.168.192.2:9200, remoteAddress=/100.79.242.17:55400} io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:499) 	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290) 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) 	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) 	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) 	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) 	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) 	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) 	at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:689) 	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:652) 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) 	at java.base/java.lang.Thread.run(Thread.java:833) Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131) 	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:378) 	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321) 	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:316) 	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkClientCerts(CertificateMessage.java:1301) 	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1204) 	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1181) 	at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396) 	at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480) 	at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1277) 	at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1264) 	at java.base/java.security.AccessController.doPrivileged(AccessController.java:712) 	at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask.run(SSLEngineImpl.java:1209) 	at io.netty.handler.ssl.SslHandler.runDelegatedTasks(SslHandler.java:1559) 	at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1405) 	at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1246) 	at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1295) 	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529) 	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468) 	... 16 more Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 	at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:439) 	at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:306) 	at java.base/sun.security.validator.Validator.validate(Validator.java:264) 	at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:285) 	at java.base/sun.security.ssl.X509TrustManagerImpl.checkClientTrusted(X509TrustManagerImpl.java:138) 	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkClientCerts(CertificateMessage.java:1279) 	... 30 more Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 	at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:146) 	at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:127) 	at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297) 	at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434) 	... 35 more

Keycloak log about the logout error:

2023-09-15 15:05:33,964 WARN  [org.keycloak.events] (executor-thread-6) type=LOGOUT_ERROR, realmId=myrealm, clientId=null, userId=null, ipAddress=*.*.*.*, error=invalid_token

Hi @szurokl,

To clarify a few things:

  • Could you please share your opensearch_dashboards.yml file content?
  • Is there a reason why you are setting up both the Certificate validation and TLS client authentication in the same setup? (for more details please refer to: OpenID Connect - OpenSearch documentation)
  • Could you please elaborate in a slightly more detail on how you are running your tests: in the same browser session (before and after node reboot), in a private (incognito) window, etc.?

Thanks,
Mantas

opensearch_dashboards.yml:

server.name: dashboards
server.host: "0.0.0.0"

opensearch.username: kibanaserver
opensearch.password: kibanaserver

server.ssl.enabled: true
server.ssl.certificate: /usr/share/opensearch-dashboards/config/certificates/dashboard.pem
server.ssl.key: /usr/share/opensearch-dashboards/config/certificates/dashboard.key

opensearch.ssl.certificateAuthorities:
          [/usr/share/opensearch-dashboards/config/certificates/server-ca.crt]
opensearch.ssl.verificationMode: full

opensearch_security.cookie.secure: true

opensearch.requestHeadersAllowlist: ["securitytenant", "Authorization"]
opensearch_security.multitenancy.enabled: true
opensearch_security.multitenancy.tenants.enable_global: true
opensearch_security.multitenancy.tenants.enable_private: true
opensearch_security.multitenancy.tenants.preferred: ["Global"]
opensearch_security.multitenancy.enable_filter: false

opensearch_security.auth.type: openid
opensearch_security.openid.connect_url: https://keycloak-url/auth/realms/myrealm/.well-known/openid-configuration
opensearch_security.openid.base_redirect_url: 'https://dashboards-url:5601'
opensearch_security.openid.client_id: opensearch-client
opensearch_security.openid.client_secret: asdf
opensearch_security.openid.root_ca: /usr/share/opensearch-dashboards/config/certificates/server-ca.crt
opensearch_security.openid.verify_hostnames: "true"

Are these options mutually exclusive? I tried enabling client auth, so the authentication happens both ways between keycloak and dashboards.

I run my tests in the same browser session all the way through and I did not use a private window.

Could you share your docker-compose.yml as well please, I am trying to get a clear picture of the infrastructure you are building.

Yes, they are, I would suggest Certificate validation only.

To avoid any expired/invalid tokens - try using a fresh session (meaning a different browser or private window). It makes troubleshooting easier.

I tested the login after a node reboot in a private window and experienced the same behavior as before.

After that I removed the client auth parts from the security config on all of the nodes and left only the certificate validation part:

...
            openid_connect_idp:
              enable_ssl: true
              verify_hostnames: true
              pemtrustedcas_filepath: /usr/share/opensearch/config/certificates/server-ca.crt
              #pemcert_filepath: /usr/share/opensearch/config/certificates/auth-client.pem
              #pemkey_filepath: /usr/share/opensearch/config/certificates/auth-client.key
              #enable_ssl_client_auth: true
            subject_key: preferred_username
            roles_key: roles
            openid_connect_url: https://keycloak-url/auth/realms/myrealm/.well-known/openid-configuration
...

After this, I rebooted the nodes one-by-one, then run securityadmin.sh to refresh the config. It seems like this fixes my problem, because I am now able to log in through keycloak without problems. I rebooted a node and I did not get 401 response code and did not see error logs in opensearch.

But. I do not understand why the two options cannot be used together. In my understanding pemtrustedcas_filepath is there so the client (dashboards) can know, that it connects to the trusted server (keycloak) and not someone else, while client cert auth is there for mTLS, so keycloak can know the trusted dashboards client is trying to connect to it, not someone else.

If I leave out pemtrustedcas_filepath and leave only the client auth parts my problem is still present, when I restart a node.

My apologies for the confusion caused, just to clarify - your understanding is correct, you can indeed enable both the client and server authentication (they are separate but their coexistence is not an issue).

The problem seems to be laying with the configuration loading:

Error loading PEM from /usr/share/opensearch/config/certificates/auth-client.key

For me to be able to try and reproduce the error in my lab could share the following:

  • your docker-compose.yml file
  • exact command(s) used to produce "pemcert_file" and "pemkey_file" (I am assuming OpenSSL was used).
  • outcomes of ls -l /usr/share/opensearch/config command on all 3 of your nodes

Moreover, is the environment in a Prod or a POC state? If it is POC, could you please redeploy with new volumes check the logs for errors then run docker stop and docker start check the logs again and share the findings?

Thanks,
Mantas

Thank you for the clarification.

I forgot to mention, but before version 2.9 I was using 2.4 (opensearch and dashboards too) and this issue was not present. I have been looking at the opensearch issues and commits on github and found this security plugin startup issue: Security Plugin cannot startup due to AccessControlException: access denied · Issue #3309 · opensearch-project/security · GitHub

from this issue:

Likely root cause: java.lang.InternalError: cannot create instance of org.bouncycastle.jcajce.provider.digest.GOST3411$Mappings : java.security.AccessControlException: access denied ("java.security.SecurityPermission" "putProviderProperty.BC")

in the opensearch logs of my original post:

Caused by: java.security.AccessControlException: access denied ("java.security.SecurityPermission" "removeProviderProperty.BC")

About the key file:

The default key I’m using is in PKCS8 format. I tried an other key which is in PEM format to see if that changes anything. In the logs I saw some errors saying OpenSearch is looking for the PKCS8 format, so my default key format should be fine.

One more detail to add:

It seems like running securityadmin.sh won’t always properly reload the configuration in OpenSearch. With pemcert_filepath and pemkey_filepath added to the configuration (with my correct PKCS8 key) when I restart a node and get 401, I can fix the issue (not permanently, just until a node restart happens again) by running touch /path/to/key and then running securityadmin.sh. Running securityadmin.sh without the touch command did not fix the 401 issue.

Thanks for the detailed update.

Could you please share the below:

  • your docker-compose.yml file
  • outcomes of ls -l /usr/share/opensearch/config command on all 3 of your nodes

Thnaks,
Mantas