# CURL - requested domain name does not match the server's certificate

**URL:** <https://community.letsencrypt.org/t/curl-requested-domain-name-does-not-match-the-servers-certificate/64931>\
**Category:** Help\
**Created:** [June 21, 2018, 2:15pm UTC](https://community.letsencrypt.org/t/curl-requested-domain-name-does-not-match-the-servers-certificate/64931 "2018-06-21T14:15:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkd4444](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/tkd4444/32/54845_2.png) [@tkd4444](https://community.letsencrypt.org/u/tkd4444)\
**Post date:** [June 21, 2018, 2:15pm UTC](https://community.letsencrypt.org/t/curl-requested-domain-name-does-not-match-the-servers-certificate/64931/1 "2018-06-21T14:15:03Z")

</div>

Hey Guys,

So I’ve successfully got a valid certificate for my domain. But when I’m trying to CURL the virtualhost which is associated with it I’m getting this error:

```
curl --verbose --header 'Host:mydomain.com' https://127.0.0.1:443/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* Server certificate:
* subject: CN=mydomain.com
* start date: Jun 21 12:30:15 2018 GMT
* expire date: Sep 19 12:30:15 2018 GMT
* common name: mydomain.com
* issuer: CN=Let's Encrypt Authority X3,O=Let's Encrypt,C=US
* NSS error -12276 (SSL_ERROR_BAD_CERT_DOMAIN)
* Unable to communicate securely with peer: requested domain name does not match the server's certificate.
* Closing connection 0
curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.

```

The Virtualhost config loos like this:

```
Listen 443 https
<VirtualHost *:443>
ServerName "${APACHE_HOSTNAME}"
RemoteIPHeader X-Forwarded-For
 RemoteIPTrustedProxy 172.31.0.0/16
 <If "req('Host') != '${APACHE_HOSTNAME}'">
    Redirect permanent / https://${APACHE_HOSTNAME}/
 </If>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/mydomain.com/cert.pem
SSLCertificateChainFile /etc/letsencrypt/live/mydomain.com/chain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
</VirtualHost>

```

The ${APACHE\_HOSTNAME} is [mydomain.com](http://mydomain.com)

When I use the -k flag with the curl I get normally connected any ideas ?

Thanks !

---

<div class="post-metadata">

**Author:** ![tob](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@tob](https://community.letsencrypt.org/u/tob)\
**Post date:** [June 21, 2018, 2:22pm UTC](https://community.letsencrypt.org/t/curl-requested-domain-name-does-not-match-the-servers-certificate/64931/2 "2018-06-21T14:22:36Z")

</div>

> [@tkd4444](#):
>
> curl --verbose --header 'Host:mydomain.com' [https://127.0.0.1:443/](https://127.0.0.1:443/)

try curl --verbose --resolve mydomain.com:443:127.0.0.1 [https://mydomain.com/](https://mydomain.com/)

---

<div class="post-metadata">

**Author:** ![tkd4444](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/tkd4444/32/54845_2.png) [@tkd4444](https://community.letsencrypt.org/u/tkd4444)\
**Post date:** [June 21, 2018, 2:26pm UTC](https://community.letsencrypt.org/t/curl-requested-domain-name-does-not-match-the-servers-certificate/64931/3 "2018-06-21T14:26:47Z")

</div>

@tob yes, this worked. Thank you. I know that the --header is being sent as a HTTP header on a different OSI layer.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/letsencrypt/original/3X/c/a/ca6c06ea1ea201324bba7048c6841ce60236468d.png) [@system](https://community.letsencrypt.org/u/system)\
**Post date:** [July 21, 2018, 2:26pm UTC](https://community.letsencrypt.org/t/curl-requested-domain-name-does-not-match-the-servers-certificate/64931/4 "2018-07-21T14:26:48Z")

</div>

Closed on July 21, 2018, 2:26pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
