3

I'm trying to test TLSv1.3 support and Apache is failing to start with the following output from systemctl status httpd...

systemd[1]: Starting The Apache HTTP Server...
httpd[6001]: AH00526: Syntax error on line 100 of /etc/httpd/conf/httpd.conf:
httpd[6001]: SSLProtocol: Illegal protocol 'TLSv1.3'
systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
systemd[1]: Failed to start The Apache HTTP Server.
systemd[1]: Unit httpd.service entered failed state.
systemd[1]: httpd.service failed.

I'm on EC2 and using Amazon Linux 2, which is limited to OpenSSL 1.0.2k, so I've manually downloaded and compiled OpenSSL 1.1.1b, and installed it in /usr/local/openssl/ leaving the original intact. To ensure the new one is used going forward I took the following steps...

  1. Created /etc/ld.so/conf.d/openssl.conf with /usr/local/openssl/lib as the content, then ran ldconfig -v to update it.

  2. Created /etc/profile.d/openssl.sh with the following content...

    #Set OPENSSL_PATH
    OPENSSL_PATH="/usr/local/openssl/bin"
    export OPENSSL_PATH
    PATH=$PATH:$OPENSSL_PATH
    export PATH
    

    ... and ran source /etc/profile.d/openssl.sh to update it.

I can confirm that which openssl is correctly pointing to /usr/local/openssl/bin/openssl, and that TLSv1.3 support is there using /usr/local/openssl/bin/openssl ciphers -V -tls1_3 -s...

0x13,0x02 - TLS_AES_256_GCM_SHA384  TLSv1.3 Kx=any      Au=any  Enc=AESGCM(256) Mac=AEAD
0x13,0x03 - TLS_CHACHA20_POLY1305_SHA256 TLSv1.3 Kx=any      Au=any  Enc=CHACHA20/POLY1305(256) Mac=AEAD
0x13,0x01 - TLS_AES_128_GCM_SHA256  TLSv1.3 Kx=any      Au=any  Enc=AESGCM(128) Mac=AEAD

Running openssl version -a produces the following...

OpenSSL 1.1.1b  26 Feb 2019
built on: Wed May 15 15:07:48 2019 UTC
platform: linux-x86_64
options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPADLOCK_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG
OPENSSLDIR: "/usr/local/openssl"
ENGINESDIR: "/usr/local/openssl/lib/engines-1.1"
Seeding source: os-specific

I am currently using Apache v2.4.39 which is supposed to support TLSv1.3 and the SSL related directives in my httpd.conf are set up as follows:

### SSL CONFIGURATION

# Session settings
SSLSessionCache shmcb:/run/httpd/sslcache(512000)
SSLSessionCacheTimeout 300
SSLProtocol -all +TLSv1.3 +TLSv1.2
SSLProxyProtocol -all +TLSv1.3 +TLSv1.2
SSLCipherSuite    TLSv1.3   TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256
SSLCipherSuite    SSL       ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256
SSLHonorCipherOrder on
SSLCompression off
SSLSessionTickets off

# OpenSSL Configuration Commands
SSLOpenSSLConfCmd DHParameters /etc/ssl/dhparam.pem
SSLOpenSSLConfCmd Curves X25519:secp521r1:secp384r1:prime256v1

# Pseudo Random Number Generator (PRNG):
SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin

# SSL Crypto Device
SSLCryptoDevice builtin

# HSTS / Header Strict Transport Security
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
Header always set X-Frame-Options SAMEORIGIN
Header always set X-Content-Type-Options nosniff

# Online Certificate Status Protocol (OCSP) Stapling
SSLUseStapling On
SSLStaplingCache "shmcb:logs/ssl_stapling(32768)"

Finally, I tried removing Apache (via Yum) and reinstalling it (via Yum), but that seemed to have zero effect.

I'm still relatively new to compiling from source, so I'm just unsure of when it's required other than circumstances like we have with OpenSSL versions, so I'm not sure if the reason I'm hitting this wall is that I need to recompile httpd from source and manually target the new OpenSSL location or what?

Any help would be greatly appreciated!

oucil
  • 4,211
  • 2
  • 37
  • 53
  • Apache will not magically pick up a new openssl installed somewhere. It will use instead the version it was compiled with. To have TLS 1.3 support in Apache you have to actually compile it with a newer OpenSSL version, just reinstalling it with yum will only reinstall the version linked against the older version of OpenSSL. – Steffen Ullrich May 16 '19 at 16:42
  • @SteffenUllrich when you say that yum will "only reinstall the version linked against the older version of OpenSSL", is that because the older version left behind files that cause this behaviour or is that linked to the OS somehow? Is there a way to either clear out those files to allow a new install to discover the new OpenSSL? Did I miss a directive somewhere that would allow yum to see the new install? Or is the only way to achieve this via a compile from source? – oucil May 16 '19 at 16:53
  • 1
    The only way is to compile from source. The build already must be aware of the newer OpenSSL version and its API, i.e. these information must be there at compile time and not only at run time. – Steffen Ullrich May 16 '19 at 17:10
  • @SteffenUllrich appreciate the help Steffen, thanks. Feel free to toss it in an answer and I'll accept it. – oucil May 16 '19 at 17:53

1 Answers1

4

The Apache version you've installed is linked against the systems OpenSSL library, i.e. OpenSSL 1.0.2k. This library has no TLS 1.3 support which also means that the necessary functions needed to configure TLS 1.3 are not available and thus cannot be used from Apache.

This does not change if you just install TLS 1.3. First, Apache will continue to use the library installed in the original path. Even if you would replace this library Apache would not be able to use the TLS 1.3 specific function since it is not aware that these functions are available in the first place.

Instead Apache needs to be rebuild against the new OpenSSL version in order to be aware of the changes in the API and to use it. A simple remove and reinstall using yum will not cause such a rebuild, but will just reinstall the version linked against the systems OpenSSL version.

Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172
  • Just to make sure I understand, if this was a fresh system, and I compiled and installed OpenSSL 1.1.1 as I outlined... If I then installed Apache via yum, would it still use the older 1.0.2k, or would it see the newer version? I guess I just don't grasp whether RPM's are "pre-compiled" using whatever the default package is for a distro, or whether they are compiled the first time they're installed via yum? – oucil May 16 '19 at 18:43
  • 1
    @oucil: yum installs binaries which are already compiled and (dynamically) linked against the original OpenSSL version. You need to have an Apache which is both compiled against and linked with the new version and you don't get this by just using yum. – Steffen Ullrich May 16 '19 at 19:08
  • 1
    Is it possible to recompile mod_ssl as a DSO rather than all of apache or are the binaries compiled with mod_ssl statically? (and forgive me if I'm using those terms inappropriately here) – oucil May 16 '19 at 19:14
  • 1
    @oucil: It could be possible to just rebuild `mod_ssl`. These modules are dynamic libraries, i.e. can be built independently from the main web server. – Steffen Ullrich May 17 '19 at 01:32