Security Workshop. Apache + SSL exercises in Ubuntu. 1 Install apache2 and enable SSL 2. 2 Generate a Local Certificate 2



Similar documents
Exercises: FreeBSD: Apache and SSL: SANOG VI IP Services Workshop

Exercises: FreeBSD: Apache and SSL: pre SANOG VI Workshop

Apache Security with SSL Using Ubuntu

Apache, SSL and Digital Signatures Using FreeBSD

LAB :: Secure HTTP traffic using Secure Sockets Layer (SSL) Certificate

SecuritySpy Setting Up SecuritySpy Over SSL

e-cert (Server) User Guide For Apache Web Server

Apache Security with SSL Using Linux

LAB :: Secure HTTP traffic using Secure Sockets Layer (SSL) Certificate

Enterprise SSL Support

APACHE HTTP SERVER 2.2.8

To enable https for appliance

Installing an SSL certificate on the InfoVaultz Cloud Appliance

Installing Dspace 1.8 on Ubuntu 12.04

CentOS. Apache. 1 de 8. Pricing Features Customers Help & Community. Sign Up Login Help & Community. Articles & Tutorials. Questions. Chat.

User s guide. APACHE SSL Linux. Using non-qualified certificates with APACHE SSL Linux. version 1.3 UNIZETO TECHNOLOGIES S.A.

ViMP 3.0. SSL Configuration in Apache 2.2. Author: ViMP GmbH

INASP: Effective Network Management Workshops

Application Note AN1502

Creating Certificate Authorities and self-signed SSL certificates

SWITCHBOARD SECURITY

Server Certificate: Apache + mod_ssl + OpenSSL

Encrypted Connections

Linux Deployment Guide. How to deploy Network Shutdown Module for Linux

Apache and Virtual Hosts Exercises

How to: Install an SSL certificate

Sun Java System Web Server 6.1 Using Self-Signed OpenSSL Certificate. Brent Wagner, Seeds of Genius October 2007

Laboratory Exercises VI: SSL/TLS - Configuring Apache Server

Browser-based Support Console

HOWTO. Configure Nginx for SSL with DoD CAC Authentication on CentOS 6.3. Joshua Penton Geocent, LLC

SSL Certificates in IPBrick

Domino and Internet. Security. IBM Collaboration Solutions. Ask the Experts 12/16/2014

SSL Tunnels. Introduction

Low cost secure VPN MikroTik SSTP over OpenIXP (Indonesian Internet) ASTA INFORMATICS Faisal Reza

Red Hat Linux Guide to Installing Root Certificates, Generating CSR and Installing SSL Certificate

CERTIFICATE-BASED SINGLE SIGN-ON FOR EMC MY DOCUMENTUM FOR MICROSOFT OUTLOOK USING CA SITEMINDER

esync - Receiving data over HTTPS

FUJITSU Cloud IaaS Trusted Public S5 Configuring a Server Load Balancer

Administering mod_jk. To Enable mod_jk

Introduction to Operating Systems

Technical specification

Network Management & Monitoring Request Tracker (RT) Installation and Configuration

Securing Your Apache Web Server With a Thawte Digital Certificate

INSTALLING KAAZING WEBSOCKET GATEWAY - HTML5 EDITION ON AN AMAZON EC2 CLOUD SERVER

Configuring Ubuntu Server as a Firewall and Reverse Proxy for OWA 2007 Configuration Guide

This section describes how to use SSL Certificates with SOA Gateway running on Linux.

Understanding SSL/TLS

Intrusion Detection and Prevention: Network and IDS Configuration and Monitoring using Snort

EventTracker Windows syslog User Guide

Installing an open source version of MateCat

By default, STRM provides an untrusted SSL certificate. You can replace the untrusted SSL certificate with a self-signed or trusted certificate.

Generating and Installing SSL Certificates on the Cisco ISA500

Crypto Lab Public-Key Cryptography and PKI

Desktop : Ubuntu Desktop, Ubuntu Desktop Server : RedHat EL 5, RedHat EL 6, Ubuntu Server, Ubuntu Server, CentOS 5, CentOS 6

Setting Up CAS with Ofbiz 5

MassTransit 6.0 Enterprise Web Configuration for Macintosh OS 10.5 Server

Configuring TLS Security for Cloudera Manager

Protect your CollabNet TeamForge site

LoadMaster SSL Certificate Quickstart Guide

Creating and Managing Certificates for My webmethods Server. Version 8.2 and Later

Network-Enabled Devices, AOS v.5.x.x. Content and Purpose of This Guide...1 User Management...2 Types of user accounts2

Managing the SSL Certificate for the ESRS HTTPS Listener Service Technical Notes P/N REV A01 January 14, 2011

Using custom certificates with Spectralink 8400 Series Handsets

10gAS SSL / Certificate Based Authentication Configuration

How To Set Up A Network Map In Linux On A Ubuntu 2.5 (Amd64) On A Raspberry Mobi) On An Ubuntu (Amd66) On Ubuntu 4.5 On A Windows Box

Securing the OpenAdmin Tool for Informix web server with HTTPS

1 Recommended Readings. 2 Resources Required. 3 Compiling and Running on Linux

GlassFish OpenSSO CAC Authentication Deployment Configuration Guide

KMIP installation Guide. DataSecure and KeySecure Version SafeNet, Inc

Customizing SSL in CA WCC r11.3 This document contains guidelines for customizing SSL access to CA Workload Control Center (CA WCC) r11.3.

Security Advice for Instances in the HP Cloud

Building a Secure RedHat Apache Server HOWTO

Configuring Secure Socket Layer and Client-Certificate Authentication on SAS 9.3 Enterprise BI Server Systems That Use Oracle WebLogic 10.

Unifying Information Security. Implementing TLS on the CLEARSWIFT SECURE Gateway

COMP 3704 Computer Security

webmethods Certificate Toolkit

CHAPTER 7 SSL CONFIGURATION AND TESTING

Contents Set up Cassandra Cluster using Datastax Community Edition on Amazon EC2 Installing OpsCenter on Amazon AMI References Contact

Install an SSL Certificate onto SilverStream. Sender Recipient Attached FIles Pages Date. Development Internal/External None 5 6/16/08

logstash The Book Log management made easy James Turnbull

Installing Apache as an HTTP Proxy to the local port of the Secure Agent s Process Server

HTTPS Configuration for SAP Connector

Implementing Secure Sockets Layer on iseries

Ciphermail Gateway Separate Front-end and Back-end Configuration Guide

CPE111 COMPUTER EXPLORATION

Proto Balance SSL TLS Off-Loading, Load Balancing. User Manual - SSL.

Configuring SSL VPN with Mac OS X and iphone Clients. Configuration tested. Network Diagram

Clearswift Information Governance

Go to Policy/Global Properties/SmartDashboard Customization, click Configure. In Certificates and PKI properties, change host_certs_key_size to 2048

RED HAT SECURE WEB SERVER 3.0 DEVELOPER EDITION FOR COBALT NETWORKS SERVERS

Apache2 Configuration under Debian GNU/Linux. Apache2 Configuration under Debian GNU/Linux

unigui Developer's Manual 2014 FMSoft Co. Ltd.

Using Client Side SSL Certificate Authentication on the WebMux

Cloud Homework instructions for AWS default instance (Red Hat based)

NetApp Storage Encryption: Preinstallation Requirements and Procedures for SafeNet KeySecure

Cisco SSL Encryption Utility

SSH and FTP on Ubuntu WNYLUG Neal Chapman 09/09/2009

Develop and Test Your PHP Applications on the IBM cloud

Transcription:

Security Workshop Apache + SSL exercises in Ubuntu Contents 1 Install apache2 and enable SSL 2 2 Generate a Local Certificate 2 3 Configure Apache to use the new certificate 4 4 Verify that http and https (Apache) are Working 5 5 Advanced Verification Methods (Optional exercise) 6 1

1 Install apache2 and enable SSL i. First we install Apache so we can get the SSL certs if you don t have it installed. In our case the server is already installed, but you can type this just to be sure. which server do you think this should be installed on? $ sudo apt-get install apache2 ii. For Ubuntu the next step is to enable SSL and restart apache $ sudo a2enmod ssl $ sudo service apache2 restart 2 Generate a Local Certificate Remember the presentation? We ll use openssl to generate a local server key, local server certificate, a certificate signing request, and a server key that is unencrypted (no passphrase) to allow Apache to start without prompting for a passphrase. This implies that you believe your server to be secure so that others don t steal your unencrypted server key and certificate and use them in nefarious (bad) ways. Realistically, however, it s not practical to have Apache ask you for a passphrase each time you boot your server. As a matter of fact this could be disastrous if, say, the power were to go out, your server reboots, and then hangs until you physically arrive to the console to type in a passphrase. Lets create the directory where we ll create our certificate. $ sudo mkdir /etc/apache2/ssl $ cd /etc/apache2/ssl Then use openssl to generate a key: $ sudo openssl genrsa -des3 -out server.key 1024 Pick a passphrase that you ll remember when prompted. Longer is better... We use triple DES encryption for the key and it s 1024 bits long. Don t make it longer, not all clients will understand how to use a longer key. Now to remove the password from our key so the web server can start SSL without asking us for a key each time. $ sudo openssl rsa -in server.key -out server.pem 2

And, you ll need to use the passphrase you just created above to do this. Before you can generate a certificate you need to create a CSR file, a Certificate Signing Request. Below is the command and a sample session you can use as an example to create your own local certificate. Note, that common name is the name of the server (dmzx.sns.nsrc.org, etc.). This is important: First the command: $ sudo openssl req -new -key server.key -out server.csr And the sample session: Country Name (2 letter code) [AU]:tz State or Province Name (full name) [Some-State]: (leave blank) Locality Name (eg, city) []:Arusha Organization Name (eg, company) [Internet Widgits Pty Ltd]:TzNOG Organizational Unit Name (eg, section) []:Workshop Common Name (eg, YOUR name) []:dmz9.sns.nsrc.org Email Address []:sysadm@dmz9.sns.nsrc.org Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: (leave blank) An optional company name []: (leave blank) Now we can sign our own certificate with our own private key as we are not sending this CSR to a CA for a commercially signed certificate. You ll need the private key passphrase again. $ sudo openssl x509 -req -days 60 -in server.csr -signkey server.key -out server.crt Note that the certficiate is only valid for 60 days. You can choose whatever number you like. This might be a typical act if you were waiting for a signed certificate from a CA, but needed to have something right away. If it all works you should see something like this: Signature ok subject=/c=tz/st=some-state/l=arusha/o=tznog/ou=workshop/cn=dmz9.sns.nsrc.org/emailaddr Getting Private key Enter pass phrase for server.key: 3

3 Configure Apache to use the new certificate Now that we have our own locally signed certificate in /etc/apache22/ssl we still need to configure Apache to actually use this certificate. Right now Apache is configured only to listen to port 80. We shall leave that running but add an SSL vhost with its own settings. Debian based distributions do this by having sample configurations in /etc/apache2/sites-available which you enable by linking in /etc/apache2/sitesenabled. This is to make administration of VirtualHosts easier. $ sudo a2ensite default-ssl $ sudo vi /etc/apache2/sites-enabled/default-ssl Look for the lines that start with the following and change them to match what we have. Now scroll down a bit further until you find the line that reads: SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem Comment that line out ( # character at front of line), and below it add the following line: SSLCertificateFile /etc/apache2/ssl/server.crt Now scroll down and find: SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key Comment this out and below it add the line: SSLCertificateKeyFile /etc/apache2/ssl/server.pem Note we used the.pem file as this is your server.key file, but without a passphrase. Save the file and exit from it at this point (in vi :wq). Restart apache using the Ubuntu system tools but in general apache ships with the script apachectl. $ sudo service apache2 reload 4

If you run in to any errors try using the log files in /var/log to troubleshoot the problem. The important files are: /var/log/messages /var/log/httpd-error.log /var/log/ssl_engine_log If you ve run in to problems or don t understand something let the instructor or an assistant know. Congratulations, you now have a secure web server up and running. 4 Verify that http and https (Apache) are Working For this exercise you can be any user. This is very simple. In the web browser of your choice go the to the following address: http://10.10.x.10/ You should have gotten the page with text: Index of / Now go to this address: https://10.10.x.10/ Depending on what version of Firefox you are using you will see different dialgoues warning you that the certificate is not trusted. Go through the process of accepting the certfificate. When you get the chance to view the certificate take a look. You see the information you filled in when generating the CSR (what s that stand for?). We ll discuss what just happened for a bit, and we ll take a look at a web browser, built-in trusted CA s, etc. 5

5 Advanced Verification Methods (Optional exercise) At the most simple level let s verify that the Apache web server daemon appears to be running. We can use the ps command to do this: $ ps auxw grep apache2 The output you should see will look something like this: root 20109 0.0 1.5 34988 7736? Ss 07:36 0:00 /usr/sbin/apache2 -k start www-data 20114 0.0 0.7 35012 3984? S 07:36 0:00 /usr/sbin/apache2 -k start www-data 20115 0.0 0.7 35012 3984? S 07:36 0:00 /usr/sbin/apache2 -k start www-data 20116 0.0 0.7 35012 3984? S 07:36 0:00 /usr/sbin/apache2 -k start www-data 20117 0.0 0.7 35012 3984? S 07:36 0:00 /usr/sbin/apache2 -k start www-data 20118 0.0 0.7 35012 3984? S 07:36 0:00 /usr/sbin/apache2 -k start root 20175 0.0 0.1 3904 812 pts/1 S+ 07:40 0:00 grep color=auto apache2 Note that Apache runs with multiple instances of the httpd daemon. This is so that the web server can rspond to multiple requests more efficiently. Also notice that the first httpd daemon that starts runs as root, but subsequent daemons use the user www-data - This is to make the web server less vulnerable to attacks that might gain root access. So, this shows you that Apache is running, but is it accessible to users with web browsers? It s possible you might be on a machine in the future and not have a web browser available, even though the machine is running a web server. You can use telnet to verify if the web server is available. To do this type: $ telnet 127.0.0.1 80 If you get back something like: Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ˆ]. This is a good indication that you have a web server working. Still, to be sure that this is not some other server running on port 80 you could go a step further. You can view the initial web server page on port 80 by doing this: 1. quit the telnet session if it s still running 6

^] [press CTRL key and ']' character to exit] telnet> quit 1. go to your home directory and try this again but saving the output to a file $ cd # [to go your home directory] $ script apache.txt # [use UNIX script utility to save session to a file] $ telnet 127.0.0.1 80 GET / HTTP/1.0 Host: localhost [press ENTER] [press ENTER twice] $ exit [to leave your script shell] And you will see the initial Apache welcome page scroll by on your screen. Now that you saved the output of this session to the file ~/apache.txt) we can get some additional information. Type the file apache.txt to your screen by doing: $ less apache.txt [remember, "q" to exit the less screen] In the first page of information presented you should see something lie: HTTP/1.1 200 OK Date: Fri, 02 Aug 2013 07:45:45 GMT Server: Apache/2.2.22 (Ubuntu) Vary: Accept-Encoding Content-Length: 525 Connection: close Content-Type: text/html;charset=utf-8 Notice that you can now see exactly what version of Apache is running. So, it appears that Apache is ssl-enabled on this machine, but how can we prove this? A web server with ssl support means that you can go to URL addresses that start with https (http secure). We ll use a tool that comes with OpenSSL to allow us to make ssl connections, verify encryption in use, view certificates, etc. You can simply type openssl and then you will get a prompt where you can use the multiple openssl tools, or you can combine the command openssl with the various tools on your command line. This is what we will do using the openssl s_client tool. Try typing these commands: $ cd $ script ssltest.txt $ openssl s_client -connect localhost:443 [Press ctrl-c to exit the information screen] $ exit $ less ssltest.txt 7

And you will get several screens of information about your Apache web server, the ssl certificate that is currently installed and it s detailed information, what protocols are in use, and more. In most cases this is overkill and you can simply use a web browser to verify functionality, but having alternatives is always nice. 8