> For the complete documentation index, see [llms.txt](https://ccie-sp.gitbook.io/ccie-spv5.1-labs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ccie-sp.gitbook.io/ccie-spv5.1-labs/labs/mdt/dial-in-with-tls.md).

# Dial-In with TLS

Configure XR1 to generate a self-signed cert and accept incoming dial-in MDT sessions on port 57400.

Transfer the self-signed cert to the NSO box in the \~/tig-stack-qos-interface-statistics directory. Do this by manually **cat**ing the file on the router, and pasting it into a file called **ROUTER-CA.pem** on the Ubuntu node.

Within the Ubuntu node, edit the **telegraf\_dial\_in.conf** file. Change the destination to **ems.cisco.com.**

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FT9wb223wsQKomJouwAF0%2Fimage.png?alt=media&amp;token=87ca0e9b-e965-476e-ac2a-3d496fb56848" alt=""><figcaption></figcaption></figure></div>

Edit the **docker-compose.yaml** file. Set the CA cert line to point to ROUTER-CA.pem. Set the method to dial\_in.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FsYsBMjSHuVitIGLlJyfp%2Fimage.png?alt=media&amp;token=32f15106-6cbc-4359-80c0-727585f5a2ba" alt=""><figcaption></figcaption></figure></div>

Edit the hosts file to include a line for **ems.cisco.com** resolving to the router’s Mgmt IP.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FNnU1vKGmn6JqxbWWorMK%2Fimage.png?alt=media&amp;token=084b2a1c-bff4-4a77-9a31-9e12b1500e8a" alt=""><figcaption></figcaption></figure></div>

Stop and then launch the container

```
sudo docker compose down
sudo docker compose up -d
```

## Answer/Explanation <a href="#id-104a06ce-5679-4b6d-82bc-6d03b31c8f91" id="id-104a06ce-5679-4b6d-82bc-6d03b31c8f91"></a>

When using dial-in, the roles are reversed. The router is now the server and the collector is the client. The router sends the collector its cert, so the collector must have the root CA installed to verify the cert.

First we must generate the self-signed cert on the router. This is done automatically when you enable gRPC server. The router generates a cert in the /misc/config/grpc directory.

```
grpc
 port 57400
```

Note that TLS is enabled by default because we did not specify **no-tls**.

The self-signed cert is now present:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FlK0B0oCm8FN5bsSetOZz%2Fimage.png?alt=media&amp;token=225b01e8-7520-43b3-bdf8-e680ebca60e8" alt=""><figcaption></figcaption></figure></div>

The file we need is **ems.pem**. We can **cat** this file and copy and paste the contents to **ROUTER-CA.pem** on the Ubuntu server. Make sure you don’t copy any extra spaces.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FnLB3sFQ9PHwJRK0HQcmA%2Fimage.png?alt=media&amp;token=7ca8350f-ef7e-4743-897e-9d11a0036078" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FbGIeTOxXUfZbxrM9WGHa%2Fimage.png?alt=media&amp;token=dd1502c7-2ef9-47f5-9ff8-e071596b57cf" alt=""><figcaption></figcaption></figure></div>

Using **openssl**, we can view the details of the cert. Notice that the CN=ems.cisco.com and there are no alternative IPs. For this reason, we changed the connection in the telegraf\_dial\_in.conf file to use this name, and added the entry to the hosts file.

```
openssl x509 -noout -text -in ROUTER-CA.pem
```

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FE0gJkHHMHKnEBHbGMANF%2Fimage.png?alt=media&amp;token=0f67bbbd-dc67-4b72-8c6b-e9bb06a3806a" alt=""><figcaption></figcaption></figure></div>

We can also see that CA:TRUE is present on this cert:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FKfv7sJp1rLPoceTUH0KU%2Fimage.png?alt=media&amp;token=779ed735-1fe5-48de-a64e-aa323972ffb2" alt=""><figcaption></figcaption></figure></div>

When you stop and restart the docker container, Telegraf will load in this cert, and use it to connect to the router.

On the router, we see that a dialin session using gRPC-TLS is present:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FLajPaIZrbHV4UcynuP1w%2Fimage.png?alt=media&amp;token=52d9d539-2ec8-4650-ae6a-a7e651c61ff7" alt=""><figcaption></figcaption></figure></div>

The destination details show that TLS is used:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FTFXgSCgdezkQFsWoWE0B%2Fimage.png?alt=media&amp;token=d520d90c-95b9-4cf5-8251-61a11556b23d" alt=""><figcaption></figcaption></figure></div>

Everything else looks just like the no-TLS dial-in session we configured previously. The only difference is that TLS is used for encryption.

Note that the command **show grpc trace ems** can be used to view logs related to gRPC TLS.
