My goal is the send traffic, for example with curl https://localhost, through a docker so that I can collect this data and see the ssl.logs for it. I have used other StackOverflow forums to get me this far but I am having issues.
So I have made my Dockerfile in the directory /docker/:
# Use the CentOS 7 base image
FROM centos:7
# Install OpenSSL and Apache HTTP Server
RUN yum install -y openssl httpd
# Copy SSL/TLS certificate and private key to appropriate directories in Docker image
COPY server.key /etc/ssl/private/
COPY server.crt /etc/ssl/certs/
# Update CA certificates inside the Docker image
RUN update-ca-certificates
# Expose port 443 for HTTPS web traffic
EXPOSE 443
# Start Apache HTTPD
CMD ["httpd", "-D", "FOREGROUND"]
In the /etc/ssl directory I have also made self signed certificates using this:
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt -subj "/CN=localhost"
Then follow instructions from other forums, I then modified by adding this to localhost.conf /etc/httpd/conf.d/localhost.conf that I made:
<VirtualHost *:443>
ServerName localhost
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key
</VirtualHost>
So, still in the /docker/ directory, I then run the docker, enable it, and then try to create the image with this:
docker build -t my-webserver.image .
But I keep getting this error: failed to solve: failed to compute cache key: failed to calculate checksum ofef ed352d55-3db7-4f44-8a8c-aa6b7d492be9::02bhon5fp3thwm1kt3ta3rncl: "/server.key"
:
So it cannot find this server key? Or it cant perform the handshake correctly? Am I missing a step or did I do something wrong?
Thank you and sorry, this is the first time I have used a docker and made self signed certificates before. I can confirm I run and enable both httpd and docker before doing anything.