How to convert ssl ciphers to curl format?

44,888

Solution 1

There is no documentation covering all of the conversions between the name of the cipher, and the name that curl is expecting as an argument.

Luckily, curl is open source, and the mapping is available in the source code.

For the benefit of future searchers, I reproduce it more neatly here:

SSL2 cipher suites

<argument>                 <name>
rc4                        SSL_EN_RC4_128_WITH_MD5
rc4-md5                    SSL_EN_RC4_128_WITH_MD5
rc4export                  SSL_EN_RC4_128_EXPORT40_WITH_MD5
rc2                        SSL_EN_RC2_128_CBC_WITH_MD5
rc2export                  SSL_EN_RC2_128_CBC_EXPORT40_WITH_MD5
des                        SSL_EN_DES_64_CBC_WITH_MD5
desede3                    SSL_EN_DES_192_EDE3_CBC_WITH_MD5

SSL3/TLS cipher suites

<argument>                 <name>
rsa_rc4_128_md5            SSL_RSA_WITH_RC4_128_MD5
rsa_rc4_128_sha            SSL_RSA_WITH_RC4_128_SHA
rsa_3des_sha               SSL_RSA_WITH_3DES_EDE_CBC_SHA
rsa_des_sha                SSL_RSA_WITH_DES_CBC_SHA
rsa_rc4_40_md5             SSL_RSA_EXPORT_WITH_RC4_40_MD5
rsa_rc2_40_md5             SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5
rsa_null_md5               SSL_RSA_WITH_NULL_MD5
rsa_null_sha               SSL_RSA_WITH_NULL_SHA
fips_3des_sha              SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA
fips_des_sha               SSL_RSA_FIPS_WITH_DES_CBC_SHA
fortezza                   SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA
fortezza_rc4_128_sha       SSL_FORTEZZA_DMS_WITH_RC4_128_SHA
fortezza_null              SSL_FORTEZZA_DMS_WITH_NULL_SHA

TLS 1.0: Exportable 56-bit Cipher Suites.

<argument>                 <name>
rsa_des_56_sha             TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA
rsa_rc4_56_sha             TLS_RSA_EXPORT1024_WITH_RC4_56_SHA

AES ciphers.

<argument>                 <name>
dhe_dss_aes_128_cbc_sha    TLS_DHE_DSS_WITH_AES_128_CBC_SHA
dhe_dss_aes_256_cbc_sha    TLS_DHE_DSS_WITH_AES_256_CBC_SHA
dhe_rsa_aes_128_cbc_sha    TLS_DHE_RSA_WITH_AES_128_CBC_SHA
dhe_rsa_aes_256_cbc_sha    TLS_DHE_RSA_WITH_AES_256_CBC_SHA
rsa_aes_128_sha            TLS_RSA_WITH_AES_128_CBC_SHA
rsa_aes_256_sha            TLS_RSA_WITH_AES_256_CBC_SHA

ECC ciphers.

<argument>                 <name>
ecdh_ecdsa_null_sha        TLS_ECDH_ECDSA_WITH_NULL_SHA
ecdh_ecdsa_rc4_128_sha     TLS_ECDH_ECDSA_WITH_RC4_128_SHA
ecdh_ecdsa_3des_sha        TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
ecdh_ecdsa_aes_128_sha     TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
ecdh_ecdsa_aes_256_sha     TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
ecdhe_ecdsa_null_sha       TLS_ECDHE_ECDSA_WITH_NULL_SHA
ecdhe_ecdsa_rc4_128_sha    TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
ecdhe_ecdsa_3des_sha       TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
ecdhe_ecdsa_aes_128_sha    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
ecdhe_ecdsa_aes_256_sha    TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
ecdh_rsa_null_sha          TLS_ECDH_RSA_WITH_NULL_SHA
ecdh_rsa_128_sha           TLS_ECDH_RSA_WITH_RC4_128_SHA
ecdh_rsa_3des_sha          TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
ecdh_rsa_aes_128_sha       TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
ecdh_rsa_aes_256_sha       TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
echde_rsa_null             TLS_ECDHE_RSA_WITH_NULL_SHA
ecdhe_rsa_rc4_128_sha      TLS_ECDHE_RSA_WITH_RC4_128_SHA
ecdhe_rsa_3des_sha         TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
ecdhe_rsa_aes_128_sha      TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
ecdhe_rsa_aes_256_sha      TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
ecdh_anon_null_sha         TLS_ECDH_anon_WITH_NULL_SHA
ecdh_anon_rc4_128sha       TLS_ECDH_anon_WITH_RC4_128_SHA
ecdh_anon_3des_sha         TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA
ecdh_anon_aes_128_sha      TLS_ECDH_anon_WITH_AES_128_CBC_SHA
ecdh_anon_aes_256_sha      TLS_ECDH_anon_WITH_AES_256_CBC_SHA

new HMAC-SHA256 cipher suites specified in RFC

<argument>                 <name>
rsa_null_sha_256                TLS_RSA_WITH_NULL_SHA256
rsa_aes_128_cbc_sha_256         TLS_RSA_WITH_AES_128_CBC_SHA256
rsa_aes_256_cbc_sha_256         TLS_RSA_WITH_AES_256_CBC_SHA256
dhe_rsa_aes_128_cbc_sha_256     TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
dhe_rsa_aes_256_cbc_sha_256     TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
ecdhe_ecdsa_aes_128_cbc_sha_256 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
ecdhe_rsa_aes_128_cbc_sha_256   TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256

AES GCM cipher suites in RFC 5288 and RFC 5289

<argument>                 <name>
rsa_aes_128_gcm_sha_256         TLS_RSA_WITH_AES_128_GCM_SHA256
dhe_rsa_aes_128_gcm_sha_256     TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
dhe_dss_aes_128_gcm_sha_256     TLS_DHE_DSS_WITH_AES_128_GCM_SHA256
ecdhe_ecdsa_aes_128_gcm_sha_256 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
ecdh_ecdsa_aes_128_gcm_sha_256  TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
ecdhe_rsa_aes_128_gcm_sha_256   TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
ecdh_rsa_aes_128_gcm_sha_256    TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256

So if you want to use the cipher TLS_DHE_RSA_WITH_AES_128_CBC_SHA, the command would be:

curl --ciphers dhe_rsa_aes_128_cbc_sha <url>

In order to specify multiple ciphers, separate the list with commas. So if you want to use the cipher TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 as well, the command would be:

curl --ciphers dhe_rsa_aes_128_cbc_sha,ecdh_rsa_aes_128_gcm_sha_256 <url>

To view a list of the ciphers that curl is using, you will need an external service - like this:

curl --ciphers ecdhe_rsa_aes_256_sha https://www.howsmyssl.com/a/check

Although NB, that service does not accept all ciphers, which means if you are restricting connection to only one cipher which is not in use, you will get an error "Cannot communicate securely with peer: no common encryption algorithm" instead of a response.

Solution 2

There is no curl format. The format of the ciphers used by curl depends on the backend which can be at least NSS, GnuTLS, SecureTransport, SChannel, OpenSSL.

But it looks like you are asking for the OpenSSL syntax. In this case see https://www.openssl.org/docs/apps/ciphers.html#CIPHER-SUITE-NAMES for a translation between the cipher names.

Share:
44,888

Related videos on Youtube

Benubird
Author by

Benubird

Updated on September 18, 2022

Comments

  • Benubird
    Benubird over 1 year

    The official ssl docs list ciphers in a different format than curl takes. For instance, if I want curl to use the cipher TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, I have to pass it curl --ciphers ecdhe_rsa_3des_sha. I know what some of the mappings are, but not all of them - for instance, what do I have to pass to curl to get it to use cipher TLS_DHE_RSA_WITH_AES_128_GCM_SHA256?

    Is there anywhere I can find a document showing how the cipher names in the ssl docs map to the cipher names that curl accepts?

    Edit: I eventually have discovered that my curl is backed by NSS, not OpenSSL, and the problem is specifically because there is no good documentation on using NSS-backed curl, while it requires a different argument than OpenSSL does to use the same cipher. So my question is specific to NSS.

  • Benubird
    Benubird almost 9 years
    No, I'm looking for the NSS ones, but the official docs for NSS doesn't have a full list.
  • Dallin
    Dallin over 8 years
    Fantastic answer, thankyou! I have just suggested a small edit to demonstrate how to specify multiple ciphers
  • user3101106
    user3101106 almost 4 years
    +1 for this answer, and -1000 to the author of nss.c for causing bad usability and confusion by doing that.