Issue with client certificate authentication (online certificate generator)

sg and es versions: 6.3.0

openjdk 1.8.0_171

So I am trying to set up TLS on my cluster. I currently have my single node cluster running using the truststore and keystore files provided with the online cert generator. I am now trying to use the demouser certificates also provided to access the cluster through curl. I tried to follow the documentation to set up client cert authentication. Within sg_config.yml I have this:

clientcert_auth_domain:

enabled: true

order: 0

http_authenticator:

type: clientcert

config:

username_attribute: demouse

challenge: false

authentication_backend:

type: noop

Now, I am not 100% sure what to actually put in the username_attribute field. In my sg_roles_mapping.yml I have this:

sg_role_starfleet:

users:

  • ‘CN=demouser’

backendroles:

  • readall

I am also not sure what to put in for users. The name of my certificate and key that I am trying to get sg to authorize are demouser.crtfull.pem and demouser.key.pem. Using openssl x509 shell command on the certificate file I get this:

"Certificate:

Data:

Version: 3 (0x2)

Serial Number: 2 (0x2)

Signature Algorithm: sha256WithRSAEncryption

Issuer: O=zeta, OU=zeta Signing CA, CN=zeta Signing CA

Validity

Not Before: Jul 3 13:03:52 2018 GMT

Not After : Jul 2 13:03:52 2020 GMT

Subject Public Key Info:

Public Key Algorithm: rsaEncryption

Public-Key: (2048 bit)

Modulus: (more here but not important)"

I am just confused as how I can get searchguard to authenticate this certificate and key pair.

Thanks

···

Subject: CN=demouser

Hm, your mapping seems correct. For certificate-based authentication, the username is the DN of the certificate so ‘CN=demouser’ would be the right one.

If you use certificate-based authentication, the internal_users.yml is not really relevant, and therefore also the user attributes entries are not relevant. The general process for cert based auth is like:

  1. Receive the client TLS certificate from the HTTP request (dependant on the ‘searchguard.ssl.http.clientauth_mode’ setting, can be NONE, OPTIONAL or REQUIRED)

  2. Validate the certificate

  3. Map the DN of the certificate to Search Guard roles

···

On Monday, July 9, 2018 at 3:08:07 PM UTC+2, Alexander Villamar wrote:

sg and es versions: 6.3.0

openjdk 1.8.0_171

So I am trying to set up TLS on my cluster. I currently have my single node cluster running using the truststore and keystore files provided with the online cert generator. I am now trying to use the demouser certificates also provided to access the cluster through curl. I tried to follow the documentation to set up client cert authentication. Within sg_config.yml I have this:

clientcert_auth_domain:

enabled: true

order: 0

http_authenticator:

type: clientcert

config:

username_attribute: demouse

challenge: false

authentication_backend:

type: noop

Now, I am not 100% sure what to actually put in the username_attribute field. In my sg_roles_mapping.yml I have this:

sg_role_starfleet:

users:

  • ‘CN=demouser’

backendroles:

  • readall

I am also not sure what to put in for users. The name of my certificate and key that I am trying to get sg to authorize are demouser.crtfull.pem and demouser.key.pem. Using openssl x509 shell command on the certificate file I get this:

"Certificate:

Data:

Version: 3 (0x2)

Serial Number: 2 (0x2)

Signature Algorithm: sha256WithRSAEncryption

Issuer: O=zeta, OU=zeta Signing CA, CN=zeta Signing CA

Validity

Not Before: Jul 3 13:03:52 2018 GMT

Not After : Jul 2 13:03:52 2020 GMT

Subject: CN=demouser

Subject Public Key Info:

Public Key Algorithm: rsaEncryption

Public-Key: (2048 bit)

Modulus: (more here but not important)"

I am just confused as how I can get searchguard to authenticate this certificate and key pair.

Thanks

Maybe my issue is in how I am trying to access the cluster via curl?

I first tried to convert the key file to jkcs #8 as I saw somewhere that the key may not be in that format. I issued this command:

“openssl pkcs8 -topk8 -in demouser.key.pem -out demouser.key -nocrypt”

I then verified that the new key requires no password and matches the old one.

I then issued the curl command:

curl -vk --cert ./demouser.crtfull.pem --key ./demouser.key “https://localhost:9200

and got this output:

  • About to connect() to localhost port 9200 (#0)

  • Trying ::1…

  • Connected to localhost (::1) port 9200 (#0)

  • Initializing NSS with certpath: sql:/etc/pki/nssdb

  • skipping SSL peer certificate verification

  • NSS: client certificate from file

···
  • subject: CN=demouser

  • start date: Jul 03 13:03:52 2018 GMT

  • expire date: Jul 02 13:03:52 2020 GMT

  • common name: demouser

  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta

  • SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384

  • Server certificate:

  • subject: CN=sgnode

  • start date: Jul 03 13:03:53 2018 GMT

  • expire date: Jul 02 13:03:53 2020 GMT

  • common name: sgnode

  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta

GET / HTTP/1.1

User-Agent: curl/7.29.0

Host: localhost:9200

Accept: /

< HTTP/1.1 401 Unauthorized

< WWW-Authenticate: Basic realm=“Search Guard”

< content-type: text/plain; charset=UTF-8

< content-length: 12

<

  • Connection #0 to host localhost left intact

Unauthorized

On Monday, July 9, 2018 at 6:03:00 PM UTC-4, Jochen Kressin wrote:

Hm, your mapping seems correct. For certificate-based authentication, the username is the DN of the certificate so ‘CN=demouser’ would be the right one.

If you use certificate-based authentication, the internal_users.yml is not really relevant, and therefore also the user attributes entries are not relevant. The general process for cert based auth is like:

  1. Receive the client TLS certificate from the HTTP request (dependant on the ‘searchguard.ssl.http.clientauth_mode’ setting, can be NONE, OPTIONAL or REQUIRED)
  1. Validate the certificate
  1. Map the DN of the certificate to Search Guard roles

On Monday, July 9, 2018 at 3:08:07 PM UTC+2, Alexander Villamar wrote:

sg and es versions: 6.3.0

openjdk 1.8.0_171

So I am trying to set up TLS on my cluster. I currently have my single node cluster running using the truststore and keystore files provided with the online cert generator. I am now trying to use the demouser certificates also provided to access the cluster through curl. I tried to follow the documentation to set up client cert authentication. Within sg_config.yml I have this:

clientcert_auth_domain:

enabled: true

order: 0

http_authenticator:

type: clientcert

config:

username_attribute: demouse

challenge: false

authentication_backend:

type: noop

Now, I am not 100% sure what to actually put in the username_attribute field. In my sg_roles_mapping.yml I have this:

sg_role_starfleet:

users:

  • ‘CN=demouser’

backendroles:

  • readall

I am also not sure what to put in for users. The name of my certificate and key that I am trying to get sg to authorize are demouser.crtfull.pem and demouser.key.pem. Using openssl x509 shell command on the certificate file I get this:

"Certificate:

Data:

Version: 3 (0x2)

Serial Number: 2 (0x2)

Signature Algorithm: sha256WithRSAEncryption

Issuer: O=zeta, OU=zeta Signing CA, CN=zeta Signing CA

Validity

Not Before: Jul 3 13:03:52 2018 GMT

Not After : Jul 2 13:03:52 2020 GMT

Subject: CN=demouser

Subject Public Key Info:

Public Key Algorithm: rsaEncryption

Public-Key: (2048 bit)

Modulus: (more here but not important)"

I am just confused as how I can get searchguard to authenticate this certificate and key pair.

Thanks

So from the output it seems that you also run an HTTP Basic authentication domain. That’s where the WWW-Authenticate: Basic realm=“Search Guard” comes from. And it also shows that the “challenge” flag in this authentication domain is set to true.

Can you please post the full content of your sg_config.yml here?

For a quick check:

  • Make sure that the client cert authentication domain comes first in the chain (order: 0)

  • If you also need Basic Authentication, this should come second (order: 1)

The check if you enabled TLS client certificates on HTTP level in elasticsearch.yml:

searchguard.ssl.http.clientauth_mode: OPTIONAL

``

If this is all correct, please set the log level to debug by following these instructions:

https://docs.search-guard.com/latest/troubleshooting-tls

Then restart Elasticsearch, issue the curl call again, and post the ES logfiles.

···

On Tuesday, July 10, 2018 at 3:34:59 PM UTC+2, Alexander Villamar wrote:

Maybe my issue is in how I am trying to access the cluster via curl?

I first tried to convert the key file to jkcs #8 as I saw somewhere that the key may not be in that format. I issued this command:

“openssl pkcs8 -topk8 -in demouser.key.pem -out demouser.key -nocrypt”

I then verified that the new key requires no password and matches the old one.

I then issued the curl command:

curl -vk --cert ./demouser.crtfull.pem --key ./demouser.key “https://localhost:9200

and got this output:

  • About to connect() to localhost port 9200 (#0)
  • Trying ::1…
  • Connected to localhost (::1) port 9200 (#0)
  • Initializing NSS with certpath: sql:/etc/pki/nssdb
  • skipping SSL peer certificate verification
  • NSS: client certificate from file
  • subject: CN=demouser
    
  • start date: Jul 03 13:03:52 2018 GMT
    
  • expire date: Jul 02 13:03:52 2020 GMT
    
  • common name: demouser
    
  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta
    
  • SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
  • Server certificate:
  • subject: CN=sgnode
    
  • start date: Jul 03 13:03:53 2018 GMT
    
  • expire date: Jul 02 13:03:53 2020 GMT
    
  • common name: sgnode
    
  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta
    

GET / HTTP/1.1

User-Agent: curl/7.29.0

Host: localhost:9200

Accept: /

< HTTP/1.1 401 Unauthorized

< WWW-Authenticate: Basic realm=“Search Guard”

< content-type: text/plain; charset=UTF-8

< content-length: 12

<

  • Connection #0 to host localhost left intact

Unauthorized

On Monday, July 9, 2018 at 6:03:00 PM UTC-4, Jochen Kressin wrote:

Hm, your mapping seems correct. For certificate-based authentication, the username is the DN of the certificate so ‘CN=demouser’ would be the right one.

If you use certificate-based authentication, the internal_users.yml is not really relevant, and therefore also the user attributes entries are not relevant. The general process for cert based auth is like:

  1. Receive the client TLS certificate from the HTTP request (dependant on the ‘searchguard.ssl.http.clientauth_mode’ setting, can be NONE, OPTIONAL or REQUIRED)
  1. Validate the certificate
  1. Map the DN of the certificate to Search Guard roles

On Monday, July 9, 2018 at 3:08:07 PM UTC+2, Alexander Villamar wrote:

sg and es versions: 6.3.0

openjdk 1.8.0_171

So I am trying to set up TLS on my cluster. I currently have my single node cluster running using the truststore and keystore files provided with the online cert generator. I am now trying to use the demouser certificates also provided to access the cluster through curl. I tried to follow the documentation to set up client cert authentication. Within sg_config.yml I have this:

clientcert_auth_domain:

enabled: true

order: 0

http_authenticator:

type: clientcert

config:

username_attribute: demouse

challenge: false

authentication_backend:

type: noop

Now, I am not 100% sure what to actually put in the username_attribute field. In my sg_roles_mapping.yml I have this:

sg_role_starfleet:

users:

  • ‘CN=demouser’

backendroles:

  • readall

I am also not sure what to put in for users. The name of my certificate and key that I am trying to get sg to authorize are demouser.crtfull.pem and demouser.key.pem. Using openssl x509 shell command on the certificate file I get this:

"Certificate:

Data:

Version: 3 (0x2)

Serial Number: 2 (0x2)

Signature Algorithm: sha256WithRSAEncryption

Issuer: O=zeta, OU=zeta Signing CA, CN=zeta Signing CA

Validity

Not Before: Jul 3 13:03:52 2018 GMT

Not After : Jul 2 13:03:52 2020 GMT

Subject: CN=demouser

Subject Public Key Info:

Public Key Algorithm: rsaEncryption

Public-Key: (2048 bit)

Modulus: (more here but not important)"

I am just confused as how I can get searchguard to authenticate this certificate and key pair.

Thanks

sg_config.yml (the only thing I believe I changed was the authc section):

searchguard:

dynamic:

http:

anonymous_auth_enabled: false

xff:

enabled: false

internalProxies: ‘192.168.0.10|192.168.0.11’ # regex pattern

remoteIpHeader: ‘x-forwarded-for’

proxiesHeader: ‘x-forwarded-by’

authc:

sic_internal_auth_domain:

enabled: true

order: 1

http_authenticator:

type: basic

challenge: true

authentication_backend:

type: internal

clientcert_auth_domain:

enabled: true

order: 0

http_authenticator:

type: clientcert

config:

username_attribute: CN=demouser

challenge: false

authentication_backend:

type: noop

authz:

roles_from_myldap:

http_enabled: false

transport_enabled: false

authorization_backend:

config:

enable_ssl: false

enable_start_tls: false

enable_ssl_client_auth: false

verify_hostnames: true

hosts:

  • localhost:8389

bind_dn: null

password: null

rolebase: ‘ou=groups,dc=example,dc=com’

rolesearch: ‘(member={0})’

userroleattribute: null

userrolename: disabled

rolename: cn

resolve_nested_roles: true

userbase: ‘ou=people,dc=example,dc=com’

usersearch: ‘(uid={0})’

roles_from_another_ldap:

enabled: false

authorization_backend:

type: ldap # NOT FREE FOR COMMERCIAL USE

In my elasticsearch.yml I have searchguard.ssl.http.clientauth_mode: OPTIONAL

The only logfile that changes after I set the tls-logging instructions and issue curl is elasticsearch.log

I have attached the entire file, the only thing that is logged when I run the curl command is

[2018-07-11T09:16:33,110][DEBUG][c.f.s.a.BackendRegistry ] Try to extract auth creds from basic http authenticator

``

I hope this helps. Once again, thank you so much for your time and effort! Great support for this product.

elasticsearch.log (34.1 KB)

···

On Tuesday, July 10, 2018 at 4:32:33 PM UTC-4, Jochen Kressin wrote:

So from the output it seems that you also run an HTTP Basic authentication domain. That’s where the WWW-Authenticate: Basic realm=“Search Guard” comes from. And it also shows that the “challenge” flag in this authentication domain is set to true.

Can you please post the full content of your sg_config.yml here?

For a quick check:

  • Make sure that the client cert authentication domain comes first in the chain (order: 0)
  • If you also need Basic Authentication, this should come second (order: 1)

The check if you enabled TLS client certificates on HTTP level in elasticsearch.yml:

searchguard.ssl.http.clientauth_mode: OPTIONAL

``

If this is all correct, please set the log level to debug by following these instructions:

https://docs.search-guard.com/latest/troubleshooting-tls

Then restart Elasticsearch, issue the curl call again, and post the ES logfiles.

On Tuesday, July 10, 2018 at 3:34:59 PM UTC+2, Alexander Villamar wrote:

Maybe my issue is in how I am trying to access the cluster via curl?

I first tried to convert the key file to jkcs #8 as I saw somewhere that the key may not be in that format. I issued this command:

“openssl pkcs8 -topk8 -in demouser.key.pem -out demouser.key -nocrypt”

I then verified that the new key requires no password and matches the old one.

I then issued the curl command:

curl -vk --cert ./demouser.crtfull.pem --key ./demouser.key “https://localhost:9200

and got this output:

  • About to connect() to localhost port 9200 (#0)
  • Trying ::1…
  • Connected to localhost (::1) port 9200 (#0)
  • Initializing NSS with certpath: sql:/etc/pki/nssdb
  • skipping SSL peer certificate verification
  • NSS: client certificate from file
  • subject: CN=demouser
    
  • start date: Jul 03 13:03:52 2018 GMT
    
  • expire date: Jul 02 13:03:52 2020 GMT
    
  • common name: demouser
    
  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta
    
  • SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
  • Server certificate:
  • subject: CN=sgnode
    
  • start date: Jul 03 13:03:53 2018 GMT
    
  • expire date: Jul 02 13:03:53 2020 GMT
    
  • common name: sgnode
    
  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta
    

GET / HTTP/1.1

User-Agent: curl/7.29.0

Host: localhost:9200

Accept: /

< HTTP/1.1 401 Unauthorized

< WWW-Authenticate: Basic realm=“Search Guard”

< content-type: text/plain; charset=UTF-8

< content-length: 12

<

  • Connection #0 to host localhost left intact

Unauthorized

On Monday, July 9, 2018 at 6:03:00 PM UTC-4, Jochen Kressin wrote:

Hm, your mapping seems correct. For certificate-based authentication, the username is the DN of the certificate so ‘CN=demouser’ would be the right one.

If you use certificate-based authentication, the internal_users.yml is not really relevant, and therefore also the user attributes entries are not relevant. The general process for cert based auth is like:

  1. Receive the client TLS certificate from the HTTP request (dependant on the ‘searchguard.ssl.http.clientauth_mode’ setting, can be NONE, OPTIONAL or REQUIRED)
  1. Validate the certificate
  1. Map the DN of the certificate to Search Guard roles

On Monday, July 9, 2018 at 3:08:07 PM UTC+2, Alexander Villamar wrote:

sg and es versions: 6.3.0

openjdk 1.8.0_171

So I am trying to set up TLS on my cluster. I currently have my single node cluster running using the truststore and keystore files provided with the online cert generator. I am now trying to use the demouser certificates also provided to access the cluster through curl. I tried to follow the documentation to set up client cert authentication. Within sg_config.yml I have this:

clientcert_auth_domain:

enabled: true

order: 0

http_authenticator:

type: clientcert

config:

username_attribute: demouse

challenge: false

authentication_backend:

type: noop

Now, I am not 100% sure what to actually put in the username_attribute field. In my sg_roles_mapping.yml I have this:

sg_role_starfleet:

users:

  • ‘CN=demouser’

backendroles:

  • readall

I am also not sure what to put in for users. The name of my certificate and key that I am trying to get sg to authorize are demouser.crtfull.pem and demouser.key.pem. Using openssl x509 shell command on the certificate file I get this:

"Certificate:

Data:

Version: 3 (0x2)

Serial Number: 2 (0x2)

Signature Algorithm: sha256WithRSAEncryption

Issuer: O=zeta, OU=zeta Signing CA, CN=zeta Signing CA

Validity

Not Before: Jul 3 13:03:52 2018 GMT

Not After : Jul 2 13:03:52 2020 GMT

Subject: CN=demouser

Subject Public Key Info:

Public Key Algorithm: rsaEncryption

Public-Key: (2048 bit)

Modulus: (more here but not important)"

I am just confused as how I can get searchguard to authenticate this certificate and key pair.

Thanks

At the moment I don’t know why this happens, but it seems the client certificate module is not loaded at all.

In your logfile I see:

[2018-07-11T09:16:06,080][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=INTERNAL_USERS_AUTHENTICATION_BACKEND, implementing class=com.floragunn.searchguard.auth.internal.InternalAuthenticationBackend]

[2018-07-11T09:16:06,080][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=HTTP_BASIC_AUTHENTICATOR, implementing class=com.floragunn.searchguard.http.HTTPBasicAuthenticator]

``

But what you should see is:

2018-07-11T16:00:20,812][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=INTERNAL_USERS_AUTHENTICATION_BACKEND, implementing class=com.floragunn.searchguard.auth.internal.InternalAuthenticationBackend]

[2018-07-11T16:00:20,816][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=HTTP_BASIC_AUTHENTICATOR, implementing class=com.floragunn.searchguard.http.HTTPBasicAuthenticator]

[2018-07-11T16:00:20,820][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=NOOP_AUTHENTICATION_BACKEND, implementing class=com.floragunn.searchguard.auth.internal.NoOpAuthenticationBackend]

[2018-07-11T16:00:20,820][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=HTTP_CLIENTCERT_AUTHENTICATOR, implementing class=com.floragunn.searchguard.http.HTTPClientCertAuthenticator]

``

This is printed on DEBUG level on node startup and when you make configuration changes with sgadmin. Are you sure you updated the configuration correctly? Because if I just copy and paste your sg_config on a test system, I can see the client_cert_authenticator bit in the logs.

···

On Wednesday, July 11, 2018 at 3:23:59 PM UTC+2, Alexander Villamar wrote:

sg_config.yml (the only thing I believe I changed was the authc section):

searchguard:

dynamic:

http:

anonymous_auth_enabled: false

xff:

enabled: false

internalProxies: ‘192.168.0.10|192.168.0.11’ # regex pattern

remoteIpHeader: ‘x-forwarded-for’

proxiesHeader: ‘x-forwarded-by’

authc:

sic_internal_auth_domain:

enabled: true

order: 1

http_authenticator:

type: basic

challenge: true

authentication_backend:

type: internal

clientcert_auth_domain:

enabled: true

order: 0

http_authenticator:

type: clientcert

config:

username_attribute: CN=demouser

challenge: false

authentication_backend:

type: noop

authz:

roles_from_myldap:

http_enabled: false

transport_enabled: false

authorization_backend:

config:

enable_ssl: false

enable_start_tls: false

enable_ssl_client_auth: false

verify_hostnames: true

hosts:

  • localhost:8389

bind_dn: null

password: null

rolebase: ‘ou=groups,dc=example,dc=com’

rolesearch: ‘(member={0})’

userroleattribute: null

userrolename: disabled

rolename: cn

resolve_nested_roles: true

userbase: ‘ou=people,dc=example,dc=com’

usersearch: ‘(uid={0})’

roles_from_another_ldap:

enabled: false

authorization_backend:

type: ldap # NOT FREE FOR COMMERCIAL USE

In my elasticsearch.yml I have searchguard.ssl.http.clientauth_mode: OPTIONAL

The only logfile that changes after I set the tls-logging instructions and issue curl is elasticsearch.log

I have attached the entire file, the only thing that is logged when I run the curl command is

[2018-07-11T09:16:33,110][DEBUG][c.f.s.a.BackendRegistry ] Try to extract auth creds from basic http authenticator

``

I hope this helps. Once again, thank you so much for your time and effort! Great support for this product.

On Tuesday, July 10, 2018 at 4:32:33 PM UTC-4, Jochen Kressin wrote:

So from the output it seems that you also run an HTTP Basic authentication domain. That’s where the WWW-Authenticate: Basic realm=“Search Guard” comes from. And it also shows that the “challenge” flag in this authentication domain is set to true.

Can you please post the full content of your sg_config.yml here?

For a quick check:

  • Make sure that the client cert authentication domain comes first in the chain (order: 0)
  • If you also need Basic Authentication, this should come second (order: 1)

The check if you enabled TLS client certificates on HTTP level in elasticsearch.yml:

searchguard.ssl.http.clientauth_mode: OPTIONAL

``

If this is all correct, please set the log level to debug by following these instructions:

https://docs.search-guard.com/latest/troubleshooting-tls

Then restart Elasticsearch, issue the curl call again, and post the ES logfiles.

On Tuesday, July 10, 2018 at 3:34:59 PM UTC+2, Alexander Villamar wrote:

Maybe my issue is in how I am trying to access the cluster via curl?

I first tried to convert the key file to jkcs #8 as I saw somewhere that the key may not be in that format. I issued this command:

“openssl pkcs8 -topk8 -in demouser.key.pem -out demouser.key -nocrypt”

I then verified that the new key requires no password and matches the old one.

I then issued the curl command:

curl -vk --cert ./demouser.crtfull.pem --key ./demouser.key “https://localhost:9200

and got this output:

  • About to connect() to localhost port 9200 (#0)
  • Trying ::1…
  • Connected to localhost (::1) port 9200 (#0)
  • Initializing NSS with certpath: sql:/etc/pki/nssdb
  • skipping SSL peer certificate verification
  • NSS: client certificate from file
  • subject: CN=demouser
    
  • start date: Jul 03 13:03:52 2018 GMT
    
  • expire date: Jul 02 13:03:52 2020 GMT
    
  • common name: demouser
    
  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta
    
  • SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
  • Server certificate:
  • subject: CN=sgnode
    
  • start date: Jul 03 13:03:53 2018 GMT
    
  • expire date: Jul 02 13:03:53 2020 GMT
    
  • common name: sgnode
    
  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta
    

GET / HTTP/1.1

User-Agent: curl/7.29.0

Host: localhost:9200

Accept: /

< HTTP/1.1 401 Unauthorized

< WWW-Authenticate: Basic realm=“Search Guard”

< content-type: text/plain; charset=UTF-8

< content-length: 12

<

  • Connection #0 to host localhost left intact

Unauthorized

On Monday, July 9, 2018 at 6:03:00 PM UTC-4, Jochen Kressin wrote:

Hm, your mapping seems correct. For certificate-based authentication, the username is the DN of the certificate so ‘CN=demouser’ would be the right one.

If you use certificate-based authentication, the internal_users.yml is not really relevant, and therefore also the user attributes entries are not relevant. The general process for cert based auth is like:

  1. Receive the client TLS certificate from the HTTP request (dependant on the ‘searchguard.ssl.http.clientauth_mode’ setting, can be NONE, OPTIONAL or REQUIRED)
  1. Validate the certificate
  1. Map the DN of the certificate to Search Guard roles

On Monday, July 9, 2018 at 3:08:07 PM UTC+2, Alexander Villamar wrote:

sg and es versions: 6.3.0

openjdk 1.8.0_171

So I am trying to set up TLS on my cluster. I currently have my single node cluster running using the truststore and keystore files provided with the online cert generator. I am now trying to use the demouser certificates also provided to access the cluster through curl. I tried to follow the documentation to set up client cert authentication. Within sg_config.yml I have this:

clientcert_auth_domain:

enabled: true

order: 0

http_authenticator:

type: clientcert

config:

username_attribute: demouse

challenge: false

authentication_backend:

type: noop

Now, I am not 100% sure what to actually put in the username_attribute field. In my sg_roles_mapping.yml I have this:

sg_role_starfleet:

users:

  • ‘CN=demouser’

backendroles:

  • readall

I am also not sure what to put in for users. The name of my certificate and key that I am trying to get sg to authorize are demouser.crtfull.pem and demouser.key.pem. Using openssl x509 shell command on the certificate file I get this:

"Certificate:

Data:

Version: 3 (0x2)

Serial Number: 2 (0x2)

Signature Algorithm: sha256WithRSAEncryption

Issuer: O=zeta, OU=zeta Signing CA, CN=zeta Signing CA

Validity

Not Before: Jul 3 13:03:52 2018 GMT

Not After : Jul 2 13:03:52 2020 GMT

Subject: CN=demouser

Subject Public Key Info:

Public Key Algorithm: rsaEncryption

Public-Key: (2048 bit)

Modulus: (more here but not important)"

I am just confused as how I can get searchguard to authenticate this certificate and key pair.

Thanks

Yes you are correct. A little embarrassed to admit but that was my issue, I didn’t update with sgadmin. I execute
curl -vk --cert ./demouser.crtfull.pem --key ./demouser.key “https://localhost:9200

``

and receive a valid response.

  • About to connect() to localhost port 9200 (#0)

  • Trying ::1…

  • Connected to localhost (::1) port 9200 (#0)

  • Initializing NSS with certpath: sql:/etc/pki/nssdb

  • skipping SSL peer certificate verification

  • NSS: client certificate from file

···
  • subject: CN=demouser

  • start date: Jul 03 13:03:52 2018 GMT

  • expire date: Jul 02 13:03:52 2020 GMT

  • common name: demouser

  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta

  • SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384

  • Server certificate:

  • subject: CN=sgnode

  • start date: Jul 03 13:03:53 2018 GMT

  • expire date: Jul 02 13:03:53 2020 GMT

  • common name: sgnode

  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta

GET / HTTP/1.1

User-Agent: curl/7.29.0

Host: localhost:9200

Accept: /

< HTTP/1.1 200 OK

< content-type: application/json; charset=UTF-8

< content-length: 493

<

{

“name” : “dod0z6s”,

“cluster_name” : “elasticsearch”,

“cluster_uuid” : “br7RJ8hZTyygtfbUmQKpKw”,

“version” : {

“number” : “6.3.0”,

“build_flavor” : “default”,

“build_type” : “tar”,

“build_hash” : “424e937”,

“build_date” : “2018-06-11T23:38:03.357887Z”,

“build_snapshot” : false,

“lucene_version” : “7.3.1”,

“minimum_wire_compatibility_version” : “5.6.0”,

“minimum_index_compatibility_version” : “5.0.0”

},

“tagline” : “You Know, for Search”

}

  • Connection #0 to host localhost left intact

Thanks for the excellent help

On Wednesday, July 11, 2018 at 10:04:13 AM UTC-4, Jochen Kressin wrote:

At the moment I don’t know why this happens, but it seems the client certificate module is not loaded at all.

In your logfile I see:

[2018-07-11T09:16:06,080][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=INTERNAL_USERS_AUTHENTICATION_BACKEND, implementing class=com.floragunn.searchguard.auth.internal.InternalAuthenticationBackend]

[2018-07-11T09:16:06,080][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=HTTP_BASIC_AUTHENTICATOR, implementing class=com.floragunn.searchguard.http.HTTPBasicAuthenticator]

``

But what you should see is:

2018-07-11T16:00:20,812][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=INTERNAL_USERS_AUTHENTICATION_BACKEND, implementing class=com.floragunn.searchguard.auth.internal.InternalAuthenticationBackend]

[2018-07-11T16:00:20,816][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=HTTP_BASIC_AUTHENTICATOR, implementing class=com.floragunn.searchguard.http.HTTPBasicAuthenticator]

[2018-07-11T16:00:20,820][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=NOOP_AUTHENTICATION_BACKEND, implementing class=com.floragunn.searchguard.auth.internal.NoOpAuthenticationBackend]

[2018-07-11T16:00:20,820][DEBUG][c.f.s.s.ReflectionHelper ] Loaded module Module [type=HTTP_CLIENTCERT_AUTHENTICATOR, implementing class=com.floragunn.searchguard.http.HTTPClientCertAuthenticator]

``

This is printed on DEBUG level on node startup and when you make configuration changes with sgadmin. Are you sure you updated the configuration correctly? Because if I just copy and paste your sg_config on a test system, I can see the client_cert_authenticator bit in the logs.

On Wednesday, July 11, 2018 at 3:23:59 PM UTC+2, Alexander Villamar wrote:

sg_config.yml (the only thing I believe I changed was the authc section):

searchguard:

dynamic:

http:

anonymous_auth_enabled: false

xff:

enabled: false

internalProxies: ‘192.168.0.10|192.168.0.11’ # regex pattern

remoteIpHeader: ‘x-forwarded-for’

proxiesHeader: ‘x-forwarded-by’

authc:

sic_internal_auth_domain:

enabled: true

order: 1

http_authenticator:

type: basic

challenge: true

authentication_backend:

type: internal

clientcert_auth_domain:

enabled: true

order: 0

http_authenticator:

type: clientcert

config:

username_attribute: CN=demouser

challenge: false

authentication_backend:

type: noop

authz:

roles_from_myldap:

http_enabled: false

transport_enabled: false

authorization_backend:

config:

enable_ssl: false

enable_start_tls: false

enable_ssl_client_auth: false

verify_hostnames: true

hosts:

  • localhost:8389

bind_dn: null

password: null

rolebase: ‘ou=groups,dc=example,dc=com’

rolesearch: ‘(member={0})’

userroleattribute: null

userrolename: disabled

rolename: cn

resolve_nested_roles: true

userbase: ‘ou=people,dc=example,dc=com’

usersearch: ‘(uid={0})’

roles_from_another_ldap:

enabled: false

authorization_backend:

type: ldap # NOT FREE FOR COMMERCIAL USE

In my elasticsearch.yml I have searchguard.ssl.http.clientauth_mode: OPTIONAL

The only logfile that changes after I set the tls-logging instructions and issue curl is elasticsearch.log

I have attached the entire file, the only thing that is logged when I run the curl command is

[2018-07-11T09:16:33,110][DEBUG][c.f.s.a.BackendRegistry ] Try to extract auth creds from basic http authenticator

``

I hope this helps. Once again, thank you so much for your time and effort! Great support for this product.

On Tuesday, July 10, 2018 at 4:32:33 PM UTC-4, Jochen Kressin wrote:

So from the output it seems that you also run an HTTP Basic authentication domain. That’s where the WWW-Authenticate: Basic realm=“Search Guard” comes from. And it also shows that the “challenge” flag in this authentication domain is set to true.

Can you please post the full content of your sg_config.yml here?

For a quick check:

  • Make sure that the client cert authentication domain comes first in the chain (order: 0)
  • If you also need Basic Authentication, this should come second (order: 1)

The check if you enabled TLS client certificates on HTTP level in elasticsearch.yml:

searchguard.ssl.http.clientauth_mode: OPTIONAL

``

If this is all correct, please set the log level to debug by following these instructions:

https://docs.search-guard.com/latest/troubleshooting-tls

Then restart Elasticsearch, issue the curl call again, and post the ES logfiles.

On Tuesday, July 10, 2018 at 3:34:59 PM UTC+2, Alexander Villamar wrote:

Maybe my issue is in how I am trying to access the cluster via curl?

I first tried to convert the key file to jkcs #8 as I saw somewhere that the key may not be in that format. I issued this command:

“openssl pkcs8 -topk8 -in demouser.key.pem -out demouser.key -nocrypt”

I then verified that the new key requires no password and matches the old one.

I then issued the curl command:

curl -vk --cert ./demouser.crtfull.pem --key ./demouser.key “https://localhost:9200

and got this output:

  • About to connect() to localhost port 9200 (#0)
  • Trying ::1…
  • Connected to localhost (::1) port 9200 (#0)
  • Initializing NSS with certpath: sql:/etc/pki/nssdb
  • skipping SSL peer certificate verification
  • NSS: client certificate from file
  • subject: CN=demouser
    
  • start date: Jul 03 13:03:52 2018 GMT
    
  • expire date: Jul 02 13:03:52 2020 GMT
    
  • common name: demouser
    
  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta
    
  • SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
  • Server certificate:
  • subject: CN=sgnode
    
  • start date: Jul 03 13:03:53 2018 GMT
    
  • expire date: Jul 02 13:03:53 2020 GMT
    
  • common name: sgnode
    
  • issuer: CN=zeta Signing CA,OU=zeta Signing CA,O=zeta
    

GET / HTTP/1.1

User-Agent: curl/7.29.0

Host: localhost:9200

Accept: /

< HTTP/1.1 401 Unauthorized

< WWW-Authenticate: Basic realm=“Search Guard”

< content-type: text/plain; charset=UTF-8

< content-length: 12

<

  • Connection #0 to host localhost left intact

Unauthorized

On Monday, July 9, 2018 at 6:03:00 PM UTC-4, Jochen Kressin wrote:

Hm, your mapping seems correct. For certificate-based authentication, the username is the DN of the certificate so ‘CN=demouser’ would be the right one.

If you use certificate-based authentication, the internal_users.yml is not really relevant, and therefore also the user attributes entries are not relevant. The general process for cert based auth is like:

  1. Receive the client TLS certificate from the HTTP request (dependant on the ‘searchguard.ssl.http.clientauth_mode’ setting, can be NONE, OPTIONAL or REQUIRED)
  1. Validate the certificate
  1. Map the DN of the certificate to Search Guard roles

On Monday, July 9, 2018 at 3:08:07 PM UTC+2, Alexander Villamar wrote:

sg and es versions: 6.3.0

openjdk 1.8.0_171

So I am trying to set up TLS on my cluster. I currently have my single node cluster running using the truststore and keystore files provided with the online cert generator. I am now trying to use the demouser certificates also provided to access the cluster through curl. I tried to follow the documentation to set up client cert authentication. Within sg_config.yml I have this:

clientcert_auth_domain:

enabled: true

order: 0

http_authenticator:

type: clientcert

config:

username_attribute: demouse

challenge: false

authentication_backend:

type: noop

Now, I am not 100% sure what to actually put in the username_attribute field. In my sg_roles_mapping.yml I have this:

sg_role_starfleet:

users:

  • ‘CN=demouser’

backendroles:

  • readall

I am also not sure what to put in for users. The name of my certificate and key that I am trying to get sg to authorize are demouser.crtfull.pem and demouser.key.pem. Using openssl x509 shell command on the certificate file I get this:

"Certificate:

Data:

Version: 3 (0x2)

Serial Number: 2 (0x2)

Signature Algorithm: sha256WithRSAEncryption

Issuer: O=zeta, OU=zeta Signing CA, CN=zeta Signing CA

Validity

Not Before: Jul 3 13:03:52 2018 GMT

Not After : Jul 2 13:03:52 2020 GMT

Subject: CN=demouser

Subject Public Key Info:

Public Key Algorithm: rsaEncryption

Public-Key: (2048 bit)

Modulus: (more here but not important)"

I am just confused as how I can get searchguard to authenticate this certificate and key pair.

Thanks