# There is no complete mTLS handshake when REST client connects to mTLS enabled opensearch ES

**URL:** https://forum.opensearch.org/t/there-is-no-complete-mtls-handshake-when-rest-client-connects-to-mtls-enabled-opensearch-es/10859
**Category:** Security
**Created:** [September 7, 2022, 6:01pm UTC](https://forum.opensearch.org/t/there-is-no-complete-mtls-handshake-when-rest-client-connects-to-mtls-enabled-opensearch-es/10859 "2022-09-07T18:01:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![lsa5521](https://avatars.discourse-cdn.com/v4/letter/l/85f322/32.png) [@lsa5521](https://forum.opensearch.org/u/lsa5521)
#### Post date: [September 7, 2022, 6:01pm UTC](https://forum.opensearch.org/t/there-is-no-complete-mtls-handshake-when-rest-client-connects-to-mtls-enabled-opensearch-es/10859/1 "2022-09-07T18:01:21Z")

</div>

Details of the issue and a reproducer are in the [[BUG]There is no complete mTLS handshake when REST client connects to mTLS enabled opensearch ES · Issue #2067 · opensearch-project/security · GitHub](https://github.com/opensearch-project/security/issues/2067) but I was asked to post it here.  
I would appreciate if someone post here working sample of mTLS enabled OpenSearch REST based client

---

<div class="post-metadata">

### Author: ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/9946_2.png) [@pablo](https://forum.opensearch.org/u/pablo)
#### Post date: [September 12, 2022, 2:21pm UTC](https://forum.opensearch.org/t/there-is-no-complete-mtls-handshake-when-rest-client-connects-to-mtls-enabled-opensearch-es/10859/2 "2022-09-12T14:21:41Z")

</div>

@lsa5521 In your example you’re using the following command to test.

```auto
curl --key conf/devpclcl1-pclmtls-client-cert-secret_key.key --cert conf/devpclcl1-pclmtls-client-cert-secret_cert.crt -XGET https://deves.pcl.psr.us-ashburn-1.ocp.oraclecloud.com:9200 -u 'admin:admin' -v

```

This command uses two types of authentication: basic and client certificate.

If the cert authentication is second and basic first then successful basic authentication (-u admin:admin) will ignore certificate authentication.

I’d like to suggest the following command to test mTLS in the OpenSearch.

```auto
curl --key conf/devpclcl1-pclmtls-client-cert-secret_key.key --cert conf/devpclcl1-pclmtls-client-cert-secret_cert.crt -XGET https://deves.pcl.psr.us-ashburn-1.ocp.oraclecloud.com:9200 -v

```

---

<div class="post-metadata">

### Author: ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/9946_2.png) [@pablo](https://forum.opensearch.org/u/pablo)
#### Post date: [September 12, 2022, 4:49pm UTC](https://forum.opensearch.org/t/there-is-no-complete-mtls-handshake-when-rest-client-connects-to-mtls-enabled-opensearch-es/10859/3 "2022-09-12T16:49:09Z")

</div>

@lsa5521 Just to be clear. The output of the curl to the OpenSearch cluster described in the README file is the expected mTLS communication.

However, according to your tests, the java REST client doesn’t use mTLS.  
Could you provide tcpdumps of your REST Client tests?

---

<div class="post-metadata">

### Author: ![lsa5521](https://avatars.discourse-cdn.com/v4/letter/l/85f322/32.png) [@lsa5521](https://forum.opensearch.org/u/lsa5521)
#### Post date: [September 12, 2022, 8:04pm UTC](https://forum.opensearch.org/t/there-is-no-complete-mtls-handshake-when-rest-client-connects-to-mtls-enabled-opensearch-es/10859/4 "2022-09-12T20:04:03Z")

</div>

@pablo Here is below the output of the SSLDUMP tool, which I used to see mTLS handshake sequence on the OpenSearch server side.

In the case of the CURL client:

ssldump -i ens3 -dnq ‘port 9200’  
New TCP connection #1: 100.100.123.173(28570) \<-\> 100.100.123.176(9200)  
1 1 0.1586 (0.1586) C\>S Handshake ClientHello  
extensions  
Short read: -2571 bytes available (expecting 2)  
1 2 0.1798 (0.0211) S\>C Handshake ServerHello  
extensions  
extended\_master\_secret  
renegotiation\_info  
ja3s string: 771,49200,23-65281  
ja3s fingerprint: ae4edc6faf64d08308082ad26be60767  
Certificate  
ServerKeyExchange  
Not enough data. Found 294 bytes (expecting 32767)  
CertificateRequest  
Not enough data. Found 592 bytes (expecting 32767)  
ServerHelloDone  
1 3 0.1957 (0.0159) C\>S Handshake Certificate  
ClientKeyExchange  
CertificateVerify  
Not enough data. Found 258 bytes (expecting 32767)  
1 4 0.1957 (0.0000) C\>S ChangeCipherSpec  
1 5 0.1957 (0.0000) C\>S Handshake  
1 6 0.2111 (0.0153) S\>C ChangeCipherSpec  
1 7 0.2111 (0.0000) S\>C Handshake  
1 8 0.2119 (0.0008) C\>S application\_data  
1 9 0.2159 (0.0040) S\>C application\_data  
1 10 0.2168 (0.0009) C\>S Alert  
1 0.2169 (0.0000) C\>S TCP FIN  
1 11 0.2174 (0.0005) S\>C Alert  
1 0.2178 (0.0003) S\>C TCP FIN

The key things here related to the client to look at are:  
CertificateRequest (server asks client to send the client certificate);  
CertificateVerify (server verifies certificate sent by client).

There is no such info in the SSLDUMP, which was collected for the OpenSearch REST with mTLS client:

ssldump -i ens3 -dnq ‘port 9200’  
New TCP connection #1: 10.98.138.71(50085) \<-\> 100.100.123.176(9200)  
1 1 0.3006 (0.3006) C\>S Handshake ClientHello  
extensions  
Short read: -324 bytes available (expecting 2)  
1 2 0.3220 (0.0213) S\>C Handshake ServerHello  
extensions  
supported\_versions  
key\_share  
ja3s string: 771,4866,43-51  
ja3s fingerprint: 15af977ce25de452b96affa2addb1036  
1 3 0.3220 (0.0000) S\>C ChangeCipherSpec  
1 4 0.3220 (0.0000) S\>C application\_data  
1 5 0.4851 (0.1630) C\>S ChangeCipherSpec  
1 6 0.8149 (0.3298) C\>S application\_data  
1 7 0.8183 (0.0034) C\>S application\_data  
1 8 0.8198 (0.0014) S\>C application\_data  
1 9 1.2064 (0.3865) S\>C application\_data  
1 1.4125 (0.2061) C\>S TCP FIN  
1 1.4127 (0.0002) S\>C TCP FIN

This looks strange because if server (OpenSearch ES in this case ) has mTLS enabled then the mTLS client should not be able to connect. But ,as I have mentioned, it works fine functionally and only concern is that there is no expected steps of the mTLS handshake in the TCPDUMP. Could it be result of some caching…?

---

<div class="post-metadata">

### Author: ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/9946_2.png) [@pablo](https://forum.opensearch.org/u/pablo)
#### Post date: [September 16, 2022, 2:48pm UTC](https://forum.opensearch.org/t/there-is-no-complete-mtls-handshake-when-rest-client-connects-to-mtls-enabled-opensearch-es/10859/5 "2022-09-16T14:48:05Z")

</div>

@lsa5521 I’ve noticed that you’ve used username and password authentication along with certificates in the RESTClient script. Have you tried to run without it, and use only certificates?

---

<div class="post-metadata">

### Author: ![lsa5521](https://avatars.discourse-cdn.com/v4/letter/l/85f322/32.png) [@lsa5521](https://forum.opensearch.org/u/lsa5521)
#### Post date: [September 19, 2022, 2:04am UTC](https://forum.opensearch.org/t/there-is-no-complete-mtls-handshake-when-rest-client-connects-to-mtls-enabled-opensearch-es/10859/6 "2022-09-19T02:04:04Z")

</div>

@pablo TLS handshake and authentication happen on different communication layers (OCI Model).  
So, the authentication would not affect the handshake.  
Anyways, I have removed the setting for authentication and results was the same - no complete mTLS handshake.  
TCPDUMP on the server side is below.  
[root@slinetsk-psrcorp ssldump-0.9b3]# /usr/sbin/ssldump -i ens3 -dnq ‘port 9200’  
New TCP connection #1: 10.74.106.233(65340) \<-\> 100.100.123.176(9200)  
1 1 0.3426 (0.3426) C\>S Handshake ClientHello  
extensions  
Short read: -324 bytes available (expecting 2)  
1 2 0.3978 (0.0551) S\>C Handshake ServerHello  
extensions  
supported\_versions  
key\_share  
ja3s string: 771,4866,43-51  
ja3s fingerprint: 15af977ce25de452b96affa2addb1036  
1 3 0.3978 (0.0000) S\>C ChangeCipherSpec  
1 4 0.3978 (0.0000) S\>C application\_data  
1 5 0.7499 (0.3520) C\>S ChangeCipherSpec  
1 6 0.8393 (0.0893) C\>S application\_data  
1 7 0.8425 (0.0032) C\>S application\_data  
1 8 0.8491 (0.0066) S\>C application\_data  
1 9 0.8520 (0.0028) S\>C application\_data
