x.509 – Are The ca Policy Values In the OpenSSL Configuration File Applied When Both Creating AND Signing Certificates?

Are the ‘ca’ policy values that are present in the OpenSSL configuration file applied when the ‘ca’ command is used to create a certificate AND when the ‘ca’ command is used to sign an existing certificate? For example, suppose the following policy section is present in an OpenSSL configuration file:

( policy_basic )
commonName                  = supplied
organizationName            = match
organizationalUnitName      = supplied
streetAddress               = optional
localityName                = match
stateOrProvinceName         = match
countryName                 = match
postalCode                  = optional
emailAddress                = optional

If I used the ‘ca’ command to generate a Certificate Signing Request (“CSR”), and no values were supplied for the “optional” policy fields, would the CSR’s Subject Name Relative Distinguished Names (“RDN”) contain the following:

commonName                  = Whatever I entered at the prompt or was stipulated as the default
organizationName            = The issuing CA certificate's Subject Name organizationName RDN
organizationalUnitName      = Whatever I entered at the prompt or was stipulated as the default
streetAddress               = Doesn't appear in CSR
localityName                = The issuing CA certificate's Subject Name localityName RDN
stateOrProvinceName         = The issuing CA certificate's Subject Name stateOrProvinceName RDN
countryName                 = The issuing CA certificate's Subject Name countryName RDN
postalCode                  = Doesn't appear in CSR
emailAddress                = Doesn't appear in CSR

Now let’s use the ‘ca’ command to sign an existing CSR. Using the values contained in the same ( policy_basic ) policy section, are the following CSR Subject Name RDN values required to be present in the CSR before the CA certificate will be allowed to sign the CSR:

commonName                  = 
organizationName            = The issuing CA certificate's Subject Name organizationName RDN
organizationalUnitName      = 
streetAddress               = 
localityName                = The issuing CA certificate's Subject Name localityName RDN
stateOrProvinceName         = The issuing CA certificate's Subject Name stateOrProvincenName RDN
countryName                 = The issuing CA certificate's Subject Name countryName RDN
postalCode                  = 
emailAddress                = 

I purposely only showed values for the CSR’s Subject Name RDNs whose corresponding policy field value is “match” in order to focus attention on how the MATCH policy value works.

Are my examples correct? If so, is it correct that the ca policy values that are present in the OpenSSL configuration file are applied when the ‘ca’ command in used to BOTH create AND sign certificates?

openssl – Nginx with only TLS1.3 cipher suites

I am trying to configure Nginx to use only TLS1.3 with 2 ciphers: TLS-AES-256-GCM-SHA384:TLS-AES-128-GCM-SHA256.

So, I tried this configuration:

ssl_protocols TLSv1.3;
ssl_ciphers TLS-AES-256-GCM-SHA384:TLS-AES-128-GCM-SHA256;

But nginx -s reload errors out with

nginx: (emerg) SSL_CTX_set_cipher_list("TLS-AES-256-GCM-SHA384:TLS-AES-128-GCM-SHA256") failed (SSL: error:1410D0B9:SSL routines:SSL_CTX_set_cipher_list:no cipher match)", "operationName": "Default", "category": "Default"}

Looks like I need to append at least one non-TLS1.3 cipher to make the config work. I tried various such combinations and they worked. One of them is:

TLS-AES-256-GCM-SHA384:TLS-AES-128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384

Why is it so? I think it’s happening because OpenSSL itself doesn’t accept the original ciphersuite string. I am using OpenSSL-1.1.1g.

root@2ed6cae6e062:/azure/appgw# openssl ciphers -v TLS-AES-256-GCM-SHA384:TLS-AES-128-GCM-SHA256
Error in cipher list
140686067873536:error:1410D0B9:SSL routines:SSL_CTX_set_cipher_list:no cipher match:ssl/ssl_lib.c:2558:

There are some useful links I came across but couldn’t figure out how to achieve what I want – using only TLS1.3 ciphersuites.

https://forum.nginx.org/read.php?2,284909,284914#msg-284914
https://trac.nginx.org/nginx/ticket/1529
https://wiki.openssl.org/index.php/TLS1.3#Ciphersuites

Uninstall LibreSSL and install OpenSSL without Homebrew

I need to install OpenSSL and uninstall LibreSSL without homebrew.

openssl version -a
LibreSSL 2.8.3
OPENSSLDIR: "/private/etc/ssl"

Searched everywhere on internet but can’t find anywhere without Homebrew.

System: macOS Catalina

private key – Openssl magic values? Secp256k1 and ECDSA similarities? What makes secp256k1 special?

Part 1:

Running this command seems to be a reliable way to produce a pubkey from a valid private key that for Bitcoin. Is this a correct assumption?

openssl ec -inform DER -text -noout -in <(cat <(echo -n "302e0201010420") <(echo -n "PRIVATE_KEY_HEX_STRING") <(echo -n "a00706052b8104000a") | xxd -r -p) 2>/dev/null | tail -6 | head -5 | sed 's/( :)//g' | tr -d 'n' && echo

These magic values:

302e0201010420

a00706052b8104000a

Openssl seems to use these values for DER encoding rules, and it doesn’t seem to have anything to do with secp256k1 or Bitcoin specifically. Is this a correct assumption?


Part 2:

It doesn’t seem like the y^2 = x^3 + 7 formula / secp256k1 is used anywhere explicitly when deriving the pubkey from the private key in the above openssl command.

Are all public keys for Elliptical Cryptography practically derived the same way.. meaning there is a ton of overlap between these ECDSA curves?

Seems like the only thing specific to Bitcoin compared to another ECDSA curve is the maximum upper limit for a private key of FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141.. is this a correct assumption? How is it that I’m able to produce the private and public keys without having to use the formula? It’s like Satoshi lied to us and this formula has no meaning!

A bit confused here would love if someone could clear this up for me and the 2 other people who can’t sleep at night because of this.

macos – Updating path openssl keeps using wrong path

I had to downgrade openssl version for mysql. But when I ran openssl version I still got the wrong version. So I checked which openssl and I saw that it’s using from anaconda:

(base) ➜  ~ which openssl
/opt/anaconda3/bin/openssl

But it needs to use:

(base) ➜  ~ ls /usr/local/Cellar/openssl
1.0.2t

So what I tried:

(base) ➜  ~ export PATH="/usr/local/Cellar/openssl/bin:$PATH"
(base) ➜  ~ source ~/.bash_profile
(base) ➜  ~ echo $PATH | tr ':' 'n'
/Library/Frameworks/Python.framework/Versions/3.8/bin
/Library/Frameworks/Python.framework/Versions/3.7/bin
/usr/local/Cellar/openssl/bin
/opt/anaconda3/bin
/opt/anaconda3/condabin
/Library/Frameworks/Python.framework/Versions/3.8/bin
/Library/Frameworks/Python.framework/Versions/3.7/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

So as you can see, my path is updated correctly. But when I run again which openssl it still gives me openssl from anaconda, what am I doing wrong here?

Getting SSL certificate from remote server with OpenSSL

I encountered a strange problem and I cannot spin my head around it.
I’m trying to validate a SSL certificate using OpenSSL from command line:

openssl s_client -showcerts -connect server.org:443

But no matter which domain on this server I call that way it delivers always the certificate of the first (alphabetically) domain on that server even if this particular domain do have own certificate. Also when I call any of this urls in browser everything works correctly

Any idea what have I done wrong?

Regards,
Radek

How to force OpenSSL to use same certificate-chain validation algorithm used by Chrome Browser and SSL LABS

Question: How can I force OpenSSL to use the same certificate validation algorithm used by the Chrome Browser and SSL Labs?

Details:

The certificate chain sent by “adswizz.com” includes a recently expired certificate from COMODO (expired May 30, 2020).

This OpenSSL command uses a simple algorithm that walks the cert-chain provided by the server, finds the expired certificate, and then reports “Verify return code: 10 (certificate has expired)”.

openssl s_client -showcerts -connect adswizz.com:443 -servername adswizz.com < /dev/null

In contrast, visiting this SSL Labs URL shows the results from a more sophisticated algorithm that explores several different paths attempting to validate the server certificate.

https://www.ssllabs.com/ssltest/analyze.html?d=adswizz.com

This finds 3 possible paths (see image below). Path #2 is the same path used by OpenSSL, so it fails due to the expired certificate, … but Paths #1 and #3 both succeed. (Path #3 even downloads an additional certicate!)

We want to use openssl from the Linux command line, and use the glib-openssl library to support TLS communication with the server. What command-line options or library config settings can we use to force OpenSSL to validate a certificate and get the same result as the Chrome Browser.

We cannot force the 3rd party running the adswizz.com to update its certificate chain because they will “check” using Chrome and tell is, “Looks valid”, … but OpenSSL will still fail.

We need a fix or a workaround. Any ideas?

Any help would be appreciated.

# openssl s_client -showcerts -connect adswizz.com:443 -servername adswizz.com < /dev/null

CONNECTED(00000003)
depth=3 C = SE, O = AddTrust AB, OU = AddTrust External TTP Network, CN = AddTrust External CA Root
verify error:num=10:certificate has expired
notAfter=May 30 10:48:38 2020 GMT
---
Certificate chain
 0 s:/OU=Domain Control Validated/OU=PositiveSSL Wildcard/CN=*.adswizz.com
   i:/C=GB/ST=Greater Manchester/L=Salford/O=Sectigo Limited/CN=Sectigo RSA Domain Validation Secure Server CA
-----BEGIN CERTIFICATE-----
MIIGczCCBVugAwIBAgIRAJmRcvO1sqghu6YYUOklMpQwDQYJKoZIhvcNAQELBQAw
gY8xCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO
BgNVBAcTB1NhbGZ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/O=Sectigo Limited/CN=Sectigo RSA Domain Validation Secure Server CA
   i:/C=US/ST=New Jersey/L=Jersey City/O=The USERTRUST Network/CN=USERTrust RSA Certification Authority
-----BEGIN CERTIFICATE-----
MIIGEzCCA/ugAwIBAgIQfVtRJrR2uhHbdBYLvFMNpzANBgkqhkiG9w0BAQwFADCB
iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl
cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV
BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTgx
MTAyMDAwMDAwWhcNMzAxMjMxMjM1OTU5WjCBjzELMAkGA1UEBhMCR0IxGzAZBgNV
BAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEYMBYGA1UE
ChMPU2VjdGlnbyBMaW1pdGVkMTcwNQYDVQQDEy5TZWN0aWdvIFJTQSBEb21haW4g
VmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
AQ8AMIIBCgKCAQEA1nMz1tc8INAA0hdFuNY+B6I/x0HuMjDJsGz99J/LEpgPLT+N
TQEMgg8Xf2Iu6bhIefsWg06t1zIlk7cHv7lQP6lMw0Aq6Tn/2YHKHxYyQdqAJrkj
eocgHuP/IJo8lURvh3UGkEC0MpMWCRAIIz7S3YcPb11RFGoKacVPAXJpz9OTTG0E
oKMbgn6xmrntxZ7FN3ifmgg0+1YuWMQJDgZkW7w33PGfKGioVrCSo1yfu4iYCBsk
Haswha6vsC6eep3BwEIc4gLw6uBK0u+QDrTBQBbwb4VCSmT3pDCg/r8uoydajotY
uK3DGReEY+1vVv2Dy2A0xHS+5p3b4eTlygxfFQIDAQABo4IBbjCCAWowHwYDVR0j
BBgwFoAUU3m/WqorSs9UgOHYm8Cd8rI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f4vmSyrcjC8azjUeqkk+B5
yOGBQMkKW+ESPMFgKuOXwIlCypTPRpgSabuY0MLTDXJLR27lk8QyKGOHQ+SwMj4K
00u/I5sUKUErmgQfky3xxzlIPK1aEn8=
-----END CERTIFICATE-----
 2 s:/C=US/ST=New Jersey/L=Jersey City/O=The USERTRUST Network/CN=USERTrust RSA Certification Authority
   i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
-----BEGIN CERTIFICATE-----
MIIFdzCCBF+gAwIBAgIQE+oocFv07O0MNmMJgGFDNjANBgkqhkiG9w0BAQwFADBv
MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk
ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF
eHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFow
gYgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpOZXcgSmVyc2V5MRQwEgYDVQQHEwtK
ZXJzZXkgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMS4wLAYD
VQQDEyVVU0VSVHJ1c3QgUlNBIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjAN
BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAgBJlFzYOw9sIs9CsVw127c0n00yt
UINh4qogTQktZAnczomfzD2p7PbPwdzx07HWezcoEStH2jnGvDoZtF+mvX2do2NC
tnbyqTsrkfjib9DsFiCQCT7i6HTJGLSR1GJk23+jBvGIGGqQIjy8/hPwhxR79uQf
jtTkUcYRZ0YIUcuGFFQ/vDP+fmyc/xadGL1RjjWmp2bIcmfbIWax1Jt4A8BQOujM
8Ny8nkz+rwWWNR9XWrf/zvk9tyy29lTdyOcSOk2uTIq3XJq0tyA9yn8iNK5+O2hm
AUTnAU5GU5szYPeUvlM3k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BIefYdgWOWnU914Ph85I6p
0fKtirOMxyHNwu8=
-----END CERTIFICATE-----
---
Server certificate
subject=/OU=Domain Control Validated/OU=PositiveSSL Wildcard/CN=*.adswizz.com
issuer=/C=GB/ST=Greater Manchester/L=Salford/O=Sectigo Limited/CN=Sectigo RSA Domain Validation Secure Server CA
---
No client certificate CA names sent
Peer signing digest: SHA512
Server Temp Key: ECDH, P-256, 256 bits
---
SSL handshake has read 5334 bytes and written 454 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES256-GCM-SHA384
    Session-ID: B56072247A34ED804A1B84933F673D5029E02352C1EC96109F38991BCE1DA450
    Session-ID-ctx: 
    Master-Key: 79A358537CE41E0CA4D3463848A9837397BB06B068547F702336723D42BB7DB0A788390E76F4264534D2B47EE2B1B48C
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 300 (seconds)
    TLS session ticket:
    0000 - 60 bb 34 9c c4 9e 1e d5-25 30 51 e8 c0 66 ad f9   `.4.....%0Q..f..
    0010 - 96 ff 5a 60 3b 9b 50 07-55 08 2b 11 5e 72 9e fb   ..Z`;.P.U.+.^r..
    0020 - b6 47 85 f1 42 27 28 ae-ce fc e0 63 c3 00 60 01   .G..B'(....c..`.
    0030 - 78 d0 6b c6 d9 40 8e 5d-96 14 a0 24 f2 4e 35 25   x.k..@.)...$.N5%
    0040 - 3e e4 94 21 c6 11 0b db-00 6b c7 16 87 c1 92 a2   >..!.....k......
    0050 - 9a c3 dc 51 95 5d 44 6f-e0 f0 20 2c 44 9e 07 e3   ...Q.)Do.. ,D...
    0060 - cb 0a 83 f2 8f 06 d8 9d-53 b8 85 a1 62 27 09 dd   ........S...b'..
    0070 - a2 74 35 31 07 71 5b 92-87 8e 84 34 c4 10 9f 01   .t51.q(....4....
    0080 - 0a 86 30 32 e4 b2 3e ed-3c c4 81 49 42 60 19 9b   ..02..>.<..IB`..
    0090 - ff 90 0b 0a a7 4b 58 ed-bd b9 6a 8a 09 3e 54 0e   .....KX...j..>T.
    00a0 - 39 ce 19 14 fb 5d b3 b6-11 a3 11 da 53 11 ff 06   9....)......S...
    00b0 - 0e 9c 1b 7f 14 ef 69 cb-35 5a 79 29 dd ed 9c 39   ......i.5Zy)...9
    00c0 - 19 e2 6a 9e d7 06 5e e7-3b 86 c1 0e cb 80 7e 6a   ..j...^.;.....~j

    Start Time: 1591065727
    Timeout   : 300 (sec)
    Verify return code: 10 (certificate has expired)
---
DONE

enter image description here

OpenSSL fails to detect expired intermediate CA certificate in s_client SSL connection test

By accident, I have an expired intermediate certificate at the end of my chain file in my Dovecot server’s SSL configuration. It’s enough of a problem that my Android e-mail client refuses to use it, although Apple Mail lets it go (??!). Indeed, the expiration just happened hours ago. openssl x509 -in ... shows:

    Serial Number:
        13:ea:28:70:5b:f4:ec:ed:0c:36:63:09:80:61:43:36
    Signature Algorithm: sha384WithRSAEncryption
    Issuer: C = SE, O = AddTrust AB, OU = AddTrust External TTP Network, CN = AddTrust External CA Root
    Validity
        Not Before: May 30 10:48:38 2000 GMT
        Not After : May 30 10:48:38 2020 GMT
    Subject: C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority

But this command:

openssl s_client -showcerts -verify_return_error -connect imap.example.com:993

fails to flag the problem (while outputting the expired certificate!). The OpenSSL package version is: 1.1.1g-1+ubuntu18.04.1+d

CONNECTED(00000003)
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = imap.example.com
verify return:1

How do I create an OpenSSL verification test to find and flag this? I have searched online already quite a bit and found nothing to address expiration down a few rungs in a public chain. The closest question is: Why is my SSL certificate untrusted on Android? but this only deals with a missing link in a 4-certificate chain. My guess as to why Apple Mail accepts the error is that MacOS has cached its own non-expired version of the same intermediate CA.

tls – Is it possible to decode an encoded PEM SSL certificate without OpenSSL in CLI?

It is said that PEM certificates are encoded with ASCII (Base64), excluding labels.
Let’s take this certificate as an example.

-----BEGIN CERTIFICATE-----
MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb
MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow
GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmlj
YXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAwMFoXDTI4MTIzMTIzNTk1OVowezEL
MAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE
BwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNVBAMM
GEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEP
ADCCAQoCggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQua
BtDFcCLNSS1UY8y2bmhGC1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe
3M/vg4aijJRPn2jymJBGhCfHdr/jzDUsi14HZGWCwEiwqJH5YZ92IFCokcdmtet4
YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszWY19zjNoFmag4qMsXeDZR
rOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjHYpy+g8cm
ez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQU
o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aYbg==

How can I decode it without OpenSSL? How to prove that this code is ASCII (Base64) ?
Could you help?

rsa – Verifying S/MIME mail with openssl

I’m trying to verify an S/MIME signed email with openssl (term tooling) but I’m having a problem.
I have the mail and I can extract the chain of certificates but I’m failing at locating the actual signature of the email. I have the public key of the signer (the last certificate) and I have the plaintext, which I got with

openssl smime -verify -in <mail> -noverify -out mail_body.txt

If I understand correctly now I need the signature, decrypt it with the last certifier public key and check that with the hash of mail_body.txt but I can’t find the signature.