11

When I visit https://somesite.org using Chrome or Firefox and inspect the server certificate, everything looks OK to me.

I see SSL Server Certificate, CN, O, OU that appears to match somesite.org issued by thawte SSL CA - G2.

But (and here I disclose that I'm new to this) using

openssl s_client -connect somesite.org:443 -showcerts

I get something very different:

depth=0 C = XX, ST = XXX, L = Strawberry Hills, O = Department
of Misadventure and Zebras, OU = Somesite, CN = www.domz.gov
verify error:num=20:unable to get local issuer certificate
verify return:1

NOTE: OU = Somesite is at odds with Dept. of Misadventure and Zebras.

Certificate chain 0 s:/C=XX/ST=XXX/L=Strawberry Hills/O=Department of Misadventure and Zebras/OU=Somesite/CN=www.domz.gov i:/C=US/O=DigiCert Inc/CN=DigiCert SHA2 Secure Server CA -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-------

If I extract the certificate and process it with

openssl x509 -in abnote.pem -text

I get a result which confirms s_client result.

5
  • Good question. I have observed similar behaviour with CloudFront. My guess: They do this to separate modern browsers from legacy browsers/tools.
    – Lukas
    Jul 20, 2018 at 12:16
  • 4
  • 2
    Which of the values in your question are accurate, and which have been redacted? In particular, is Dept. of Misadventure and Zebras. what you actually see?
    – marcelm
    Jul 20, 2018 at 15:01
  • 1
    This question needs some serious formatting fixes. Jul 20, 2018 at 16:16
  • @marcelm, should I un-redact values? and no, Dept. of Misadventure and Zebras is not real... unfortunately. Jul 21, 2018 at 11:07

2 Answers 2

17

Unsure for your exact use case, but that is what the Server Name Indication TLS extension precisely addresses.

In HTTPS, the SSL handshake where the server presents its certificate occurs before the server could examine any HTTP header. SNI allows the client to send the name of the virtual domain as part of the TLS negotiation.This enables the server to select one certificate among many. Therefore, with clients and servers that implement SNI, a server with a single IP address can serve different domain names with different certificates.

SNI was added to the IETF's Internet RFCs in June 2003 through RFC 3546, Transport Layer Security (TLS) Extensions. The latest version of the standard is RFC 6066.

It is now the de-facto standard, because in large datacenters the front proxies can serve hundreds or thousands of sites, not speaking of Content Delivery Networks like Akamai or CloudFront (thanks to Mike Ounsworth for that part)

More details on the referenced page.


BTW, openssl can use SNI with the servername option:

openssl s_client -connect somesite.org:443 -servername somesite.org -showcerts

should be enough to get same certificates than browsers get

7
  • 1
    Great answer. You should add that with something like CloudFront, the front-end server hosts thousands of web sites and has no idea which cert to present unless you tell it via the SNI extension. Jul 20, 2018 at 13:19
  • @MikeOunsworth: Thanks for the feed back. I've edited my post with your comment. Jul 20, 2018 at 13:31
  • 1
    IMHO, openssl should have made SNI -servername by default ;-). Many openssl seems unaware of SNI.
    – mootmoot
    Jul 20, 2018 at 13:51
  • 3
    @mootmoot: I assume they did not for compatibility reasons... Jul 20, 2018 at 14:05
  • I redacted most detail because I was unsure if this would acceptable. I can re-add it, but I'll try -servername option first. Thanks. Jul 21, 2018 at 10:56
-1

If you are on the network of your company, school, or other organization, your browser might be set up to use a web proxy server. Look for that in your browser or system network settings.

If the browser is using a proxy but s_client is not, s_client may end up at some internal site that tells you to set up the proxy, and that site will not have the expected certificate.

This answer tells how to use a proxy with s_client: openssl s_client using a proxy.

1
  • I am not behind a proxy, but thanks for your thought. Jul 21, 2018 at 11:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .