-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix BadSSL by building everything from source (#3331)
## Motivation and Context The TLS test broke. Why? Because Bad SSL stopped working. Why did BadSSL stop working? Because it used an ancient version of ruby and it couldn't install packages anymore. So I: - Got it working on a newer version of ruby - But that only work on Ubuntu 22.04. - The version of nginx/openssl that you can install on 22.04 version actually serve these terrible certificates. So instead, we compile nginx and openssl from source. I also fixed things up so they won't fail silently in the future. <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here --> ## Description Mostly just sadness. ## Testing The check passes again. ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
- Loading branch information
Showing
2 changed files
with
101 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Why does this file exist? | ||
# badssl seems to be abandoned. The orginal Dockerfile was based on ubuntu 16.04 and all the bits were rotting. | ||
# I've updated the Dockerfilet l to ubuntu 22.04 which will hopefully let everything limp along a little longer. | ||
FROM ubuntu:22.04 as nginx | ||
# Install necessary packages for building NGINX | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
libpcre3 \ | ||
libpcre3-dev \ | ||
zlib1g \ | ||
zlib1g-dev \ | ||
wget | ||
|
||
# Define NGINX version (this is the old version from ubuntu 16.04 to match) | ||
ARG NGINX_VERSION=1.14.2 | ||
ARG OPEN_SSL_VERSION=1.0.2g | ||
|
||
RUN wget https://www.openssl.org/source/openssl-${OPEN_SSL_VERSION}.tar.gz \ | ||
&& tar -xzvf openssl-${OPEN_SSL_VERSION}.tar.gz | ||
|
||
# Download NGINX source code | ||
RUN wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz \ | ||
&& tar -xzvf nginx-$NGINX_VERSION.tar.gz \ | ||
&& cd nginx-$NGINX_VERSION | ||
|
||
|
||
# Configure NGINX before building it | ||
RUN cd nginx-$NGINX_VERSION \ | ||
&& ./configure \ | ||
--prefix=/usr/local/nginx \ | ||
--with-http_ssl_module \ | ||
--with-openssl=../openssl-${OPEN_SSL_VERSION} \ | ||
--with-openssl-opt=enable-weak-ssl-ciphers \ | ||
--with-stream \ | ||
--with-threads \ | ||
&& make -j 6 \ | ||
&& make install -j 6 | ||
|
||
RUN /usr/local/nginx/sbin/nginx -V | ||
|
||
FROM ubuntu:22.04 | ||
|
||
EXPOSE 80 443 | ||
RUN apt-get update && apt-get install -y apt-transport-https | ||
RUN apt-get install -y software-properties-common | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
git \ | ||
libffi-dev \ | ||
make \ | ||
ruby3.0 \ | ||
ruby3.0-dev | ||
#RUN gem update --system | ||
RUN gem install jekyll | ||
|
||
COPY --from=nginx /usr/local/nginx /usr/local/nginx | ||
ENV PATH="/usr/local/nginx/sbin:${PATH}" | ||
|
||
# Install badssl.com | ||
ADD . badssl.com | ||
WORKDIR badssl.com | ||
|
||
RUN sed -i 's/SECLEVEL=2/SECLEVEL=0/' /etc/ssl/openssl.cnf | ||
RUN tail -n10 /etc/ssl/openssl.cnf | ||
|
||
RUN nginx -V | ||
RUN mkdir /etc/nginx | ||
# `make-in-docker` requires this file to exist. | ||
RUN ln -s /usr/local/nginx/conf/nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Update the nginx config to include the badssl configs. | ||
RUN head -n-1 /etc/nginx/nginx.conf > wip.conf | ||
RUN echo "# Virtual Host Configs\ninclude /var/www/badssl/_site/nginx.conf;\n}" >> wip.conf | ||
RUN mv wip.conf /usr/local/nginx/conf/nginx.conf | ||
RUN make inside-docker | ||
|
||
# Allow unsecure certs | ||
RUN sed -i 's/SECLEVEL=2/SECLEVEL=0/' /etc/ssl/openssl.cnf | ||
|
||
# Fix DH key that can't be generated...works in docker bug not on github. Who knows. | ||
RUN echo "-----BEGIN DH PARAMETERS-----" > /var/www/badssl/_site/certs/sets/current/gen/dhparam/dh480.pem | ||
RUN echo "MEICPQDZ/YFp3iEs3/k9iRGoC/5/To2+5pUF/C6GkO6VjXHHyRVy68I0rI0q7IAq" >> /var/www/badssl/_site/certs/sets/current/gen/dhparam/dh480.pem | ||
RUN echo "VyyGQ7/5Q/Iu0QQnHT4X9uMCAQI=" >> /var/www/badssl/_site/certs/sets/current/gen/dhparam/dh480.pem | ||
RUN echo "-----END DH PARAMETERS-----" >> /var/www/badssl/_site/certs/sets/current/gen/dhparam/dh480.pem | ||
|
||
RUN nginx -t | ||
# Start things up! | ||
CMD nginx && tail -f /usr/local/nginx/logs/access.log /usr/local/nginx/logs/error.log |