and when I search using the user's client certificate I got 403:
certs curl https://localhost:9200/test_index/_search
--key testuser.key --cert testuser.crt --cacert intermediates.pem -k -v
< HTTP/1.1 403 Forbidden
< content-type: application/json; charset=UTF-8
< content-length: 311
<
Connection #0 to host localhost left intact
{"error":{"root_cause":[{"type":"security_exception","reason":"action [indices:data/read/search] is unauthorized for user [testuser]"}],"type":"security_exception","reason":"action [indices:data/read/search] is unauthorized for user [testuser]"},"status":403}%
The user you created via the API is a native realm user. It has no relationship with the user that is authenticated via PKI except for having the same username.
You do not need to define a native user for each of your PKI users, users that authenticate via the PKI realm are emphemeral they exist simply by virtue of authenticating.
So, in your example you are getting a 403 because you authenticated as a PKI user, but that user has no roles.
Thanks a lot. that makes a lot of sense. However I'm getting No handler found when I try to create the mapping:
➜ certs curl -u elastic:changeme -k -v -X POST -d '{"roles":["superuser","testkibana"],"rules":{"field":{"dn":"cn=testuser"}},"enabled":true}' 'https://localhost:9200/_xpack/security/role_mapping/testuser'
Note: Unnecessary use of -X or --request, POST is already inferred.
upload completely sent off: 118 out of 118 bytes
< HTTP/1.1 400 Bad Request
< content-type: text/plain; charset=UTF-8
< content-length: 109
<
Connection #0 to host localhost left intact
No handler found for uri [/_xpack/security/role_mapping/elasticsearch.kibana.social.ea.com] and method [POST]%
That is an ancient version (released more than 2 years ago).
I'll do my best to help, but we've fixed a lot of bugs since then, and my memory of exactly what is in each version gets fuzzy the further back we go.
Are you sure you can't upgrade? You're making your life very difficult and if you raise a case with our support team they'll have difficulty supporting you on an old EOL version.
That metadata field didn't exist in 5.2
PKI works in 5.2, it's just harder to set up since there's no API and no metadata to inspect.
You're probably entering the wrong DN in the role mapping file. Openssl reports DNs in format from parent RDN to child RDN (e.g. DC=com, DC=example, OU=users, CN=john)
Elasticsearch uses the LDAP/X.500 style format of child-first e.g. CN=john,OU=users,DC=example,DC=com)
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.