# Client Certificate Authentication not picking up the CN

**URL:** <https://forum.search-guard.com/t/client-certificate-authentication-not-picking-up-the-cn/1201>\
**Category:** Search Guard\
**Created:** [November 20, 2018, 10:24pm UTC](https://forum.search-guard.com/t/client-certificate-authentication-not-picking-up-the-cn/1201 "2018-11-20T22:24:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malavika\_Yuvaraj](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@Malavika\_Yuvaraj](https://forum.search-guard.com/u/Malavika_Yuvaraj)\
**Post date:** [November 20, 2018, 10:24pm UTC](https://forum.search-guard.com/t/client-certificate-authentication-not-picking-up-the-cn/1201/1 "2018-11-20T22:24:19Z")

</div>

When asking questions, please provide the following information:

- Search Guard and Elasticsearch version

- Installed and used enterprise modules, if any

- JVM version and operating system version

- Search Guard configuration files

- Elasticsearch log messages on debug level

- Other installed Elasticsearch or Kibana plugins, if any

SG/ES - 6.4.2-15

No enterprise modules

java version “1.8.0\_191”

Searchguard config files

**sg\_config.yml**

basic\_internal\_auth\_domain:

http\_enabled: true

transport\_enabled: true

order: 1

http\_authenticator:

type: basic

challenge: false

authentication\_backend:

type: internal

clientcert\_auth\_domain:

http\_enabled: true

transport\_enabled: true

order: 0

http\_authenticator:

type: clientcert

config:

username\_attribute: cn=esclient

challenge: false

authentication\_backend:

type: noop

**sg\_roles\_mapping.yml**

sg\_readall:

readonly: true

backendroles:

- readall

users:

- ''cn=esclient"

**curl call:**

curl -vk ‘[https://esclient-0:9200/\_search](https://esclient-0:9200/_search)’ --cacert ./ca.pem --key ./key.dec.pem --cert ./cl.pem

- Trying 10.5.0.42…

- Connected to esclient-0 (10.5.0.42) port 9200 (#0)

- found 2 certificates in ./ca.pem

- found 600 certificates in /etc/ssl/certs

- ALPN, offering http/1.1

- SSL connection using TLS1.2 / ECDHE\_RSA\_AES\_128\_GCM\_SHA256

- 

```
   server certificate verification SKIPPED

```

- 

```
   server certificate status verification SKIPPED

```

- 

```
   common name: esclient-servercert (does not match 'esclient-0')

```

- 

```
   server certificate expiration date OK

```

- 

```
   server certificate activation date OK

```

- 

```
   certificate public key: RSA

```

- 

```
   certificate version: #3

```

- 

```
   start date: Fri, 09 Nov 2018 16:55:28 GMT

```

- 

```
   expire date: Mon, 09 Nov 2020 16:55:28 GMT

```

- 

```
   compression: NULL

```

- ALPN, server did not agree to a protocol

> GET /\_search HTTP/1.1

> Host: esIntclient-0:9200

> User-Agent: curl/7.47.0

> Accept: _/_

> 

\< HTTP/1.1 401 Unauthorized

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

\< content-length: 29

\<

- Connection #0 to host esclient-0 left intact

Authentication finally failed

[2018-11-20T22:22:18,397][TRACE][c.f.s.a.BackendRegistry] Try to extract auth creds from clientcert http authenticator

[2018-11-20T22:22:18,397][TRACE][c.f.s.h.HTTPClientCertAuthenticator] No CLIENT CERT, send 401

[2018-11-20T22:22:18,398][TRACE][c.f.s.a.BackendRegistry] No ‘Authorization’ header, send 403

[2018-11-20T22:22:18,398][TRACE][c.f.s.a.BackendRegistry] Try to extract auth creds from basic http authenticator

[2018-11-20T22:22:18,398][TRACE][c.f.s.a.BackendRegistry] No ‘Authorization’ header, send 403

[2018-11-20T22:22:18,398][DEBUG][c.f.s.a.BackendRegistry] User still not authenticated after checking 2 auth domains

[2018-11-20T22:22:18,398][WARN][c.f.s.a.BackendRegistry] Authentication finally failed for null

I am trying to set up permissions for non-admin certs.Could someone please take a look and point out what may be wrong here? Thanks!

> **···**
>
> - 
> 
> ```
> subject: CN=esclient-int-servercert
> 
> ```

---

<div class="post-metadata">

**Author:** ![jkressin](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.search-guard.com/jkressin/32/9_2.png) [@jkressin](https://forum.search-guard.com/u/jkressin)\
**Post date:** [November 28, 2018, 11:05am UTC](https://forum.search-guard.com/t/client-certificate-authentication-not-picking-up-the-cn/1201/2 "2018-11-28T11:05:27Z")

</div>

Have you set the clientauth\_mode to at least OPTIONAL?

> **[Client certificate authentication](https://docs.search-guard.com/latest/client-certificate-auth)**
>
> How to use client side TLS certificates to protect Elasticsearch against unauthorized access.

Also, this config entry here seems incorrect:

```
      config:
        username_attribute: cn=esclient

```

``

It should be:

```
      config:
        username_attribute: cn

```

``

The username\_attribute just tells SG which part of the DN it should use as username.

> **···**
>
> On Tuesday, November 20, 2018 at 11:15:46 PM UTC+1, Malavika Yuvaraj wrote:
> 
> > When asking questions, please provide the following information:
> 
> > - Search Guard and Elasticsearch version
> 
> > - Installed and used enterprise modules, if any
> 
> > - JVM version and operating system version
> 
> > - Search Guard configuration files
> 
> > - Elasticsearch log messages on debug level
> 
> > - Other installed Elasticsearch or Kibana plugins, if any
> 
> > 
> 
> > SG/ES - 6.4.2-15
> 
> > No enterprise modules
> 
> > java version “1.8.0\_191”
> 
> > 
> 
> > Searchguard config files
> 
> > **sg\_config.yml**
> 
> > basic\_internal\_auth\_domain:
> 
> > http\_enabled: true
> 
> > transport\_enabled: true
> 
> > order: 1
> 
> > http\_authenticator:
> 
> > type: basic
> 
> > challenge: false
> 
> > authentication\_backend:
> 
> > type: internal
> 
> > clientcert\_auth\_domain:
> 
> > http\_enabled: true
> 
> > transport\_enabled: true
> 
> > order: 0
> 
> > http\_authenticator:
> 
> > type: clientcert
> 
> > config:
> 
> > username\_attribute: cn=esclient
> 
> > challenge: false
> 
> > authentication\_backend:
> 
> > type: noop
> 
> > 
> 
> > **sg\_roles\_mapping.yml**
> 
> > sg\_readall:
> 
> > readonly: true
> 
> > backendroles:
> 
> > - readall
> 
> > users:
> 
> > - ''cn=esclient"
> 
> > 
> 
> > **curl call:**
> 
> > curl -vk ‘[https://esclient-0:9200/\_search](https://esclient-0:9200/_search)’ --cacert ./ca.pem --key ./key.dec.pem --cert ./cl.pem
> 
> > - Trying 10.5.0.42…
> 
> > - Connected to esclient-0 (10.5.0.42) port 9200 (#0)
> 
> > - found 2 certificates in ./ca.pem
> 
> > - found 600 certificates in /etc/ssl/certs
> 
> > - ALPN, offering http/1.1
> 
> > - SSL connection using TLS1.2 / ECDHE\_RSA\_AES\_128\_GCM\_SHA256
> 
> > - 
> > 
> > ```
> > server certificate verification SKIPPED
> > 
> > ```
> 
> > - 
> > 
> > ```
> > server certificate status verification SKIPPED
> > 
> > ```
> 
> > - 
> > 
> > ```
> > common name: esclient-servercert (does not match 'esclient-0')
> > 
> > ```
> 
> > - 
> > 
> > ```
> > server certificate expiration date OK
> > 
> > ```
> 
> > - 
> > 
> > ```
> > server certificate activation date OK
> > 
> > ```
> 
> > - 
> > 
> > ```
> > certificate public key: RSA
> > 
> > ```
> 
> > - 
> > 
> > ```
> > certificate version: #3
> > 
> > ```
> 
> > - 
> > 
> > ```
> > subject: CN=esclient-int-servercert
> > 
> > ```
> 
> > - 
> > 
> > ```
> > start date: Fri, 09 Nov 2018 16:55:28 GMT
> > 
> > ```
> 
> > - 
> > 
> > ```
> > expire date: Mon, 09 Nov 2020 16:55:28 GMT
> > 
> > ```
> 
> > - 
> > 
> > ```
> > compression: NULL
> > 
> > ```
> 
> > - ALPN, server did not agree to a protocol
> 
> > > GET /\_search HTTP/1.1
> 
> > > Host: esIntclient-0:9200
> 
> > > User-Agent: curl/7.47.0
> 
> > > Accept: _/_
> 
> > >
> 
> > \< HTTP/1.1 401 Unauthorized
> 
> > \< content-type: text/plain; charset=UTF-8
> 
> > \< content-length: 29
> 
> > \<
> 
> > - Connection #0 to host esclient-0 left intact
> 
> > Authentication finally failed
> 
> > 
> 
> > [2018-11-20T22:22:18,397][TRACE][c.f.s.a.BackendRegistry] Try to extract auth creds from clientcert http authenticator
> 
> > [2018-11-20T22:22:18,397][TRACE][c.f.s.h.HTTPClientCertAuthenticator] No CLIENT CERT, send 401
> 
> > [2018-11-20T22:22:18,398][TRACE][c.f.s.a.BackendRegistry] No ‘Authorization’ header, send 403
> 
> > [2018-11-20T22:22:18,398][TRACE][c.f.s.a.BackendRegistry] Try to extract auth creds from basic http authenticator
> 
> > [2018-11-20T22:22:18,398][TRACE][c.f.s.a.BackendRegistry] No ‘Authorization’ header, send 403
> 
> > [2018-11-20T22:22:18,398][DEBUG][c.f.s.a.BackendRegistry] User still not authenticated after checking 2 auth domains
> 
> > [2018-11-20T22:22:18,398][WARN][c.f.s.a.BackendRegistry] Authentication finally failed for null
> 
> > 
> 
> > I am trying to set up permissions for non-admin certs.Could someone please take a look and point out what may be wrong here? Thanks!
