SSL/TLS Hands-on Thomas Herlea



Similar documents
X.509 and SSL. A look into the complex world of X.509 and SSL UUASC 07/05/07. Phil Dibowitz

Certificate Management. PAN-OS Administrator s Guide. Version 7.0

Certificates and network security

SSL Certificates in IPBrick

Digital Certificates (Public Key Infrastructure) Reshma Afshar Indiana State University

X.509 Certificate Generator User Manual

Encrypted Connections

Bugzilla ID: Bugzilla Summary:

Enabling SSL and Client Certificates on the SAP J2EE Engine

Laboratory Exercises VI: SSL/TLS - Configuring Apache Server

Certificate Management

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

Crypto Lab Public-Key Cryptography and PKI

[SMO-SFO-ICO-PE-046-GU-

SBClient SSL. Ehab AbuShmais

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

Cisco Expressway Certificate Creation and Use

Building a Secure RedHat Apache Server HOWTO

Netzwerksicherheit Übung 6 SSL/TLS, OpenSSL

Public Key Infrastructure

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

Apache Security with SSL Using Linux

Apache Security with SSL Using Ubuntu

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

Installing an SSL certificate on the InfoVaultz Cloud Appliance

Public Key Infrastructure (PKI)

Integrated SSL Scanning

Displaying SSL Certificate and Key Pair Information

Creation and Management of Certificates


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

ASA 8.x Manually Install 3rd Party Vendor Certificates for use with WebVPN Configuration Example

SSL Interception on Proxy SG

OpenCA v (ten-ten 2 )

Cisco TelePresence VCS Certificate Creation and Use

Cisco TelePresence VCS Certificate Creation and Use

WiMAX Public Key Infrastructure (PKI) Users Overview

SecuritySpy Setting Up SecuritySpy Over SSL

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

Digital Certificates Demystified

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

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

Apache, SSL and Digital Signatures Using FreeBSD

SSL Certificates HOWTO

Do Web Browsers Obey Best Practices When Validating Digital Certificates?

Whitepaper : Using Unsniff Network Analyzer to analyze SSL / TLS

Using EMC Unisphere in a Web Browsing Environment: Browser and Security Settings to Improve the Experience

HMRC Secure Electronic Transfer (SET)

Avoid the SSLippery Slope of Default SSL

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

Configuration Guide for RFMS 3.0 Initial Configuration. WiNG 5 How-To Guide. Digital Certificates. July 2011 Revision 1.0

Factory Application Certificates and Keys Products: SB700EX, SB70LC

Creating Certificate Authorities and self-signed SSL certificates

Understanding digital certificates

Virtual Private Network with OpenVPN

DoD Public Key Enablement (PKE) Quick Reference Guide. Securing Apache HTTP with mod_ssl for Linux

Acano solution. Certificate Guidelines R1.7. for Single Combined Acano Server Deployments. December H

Configuring SSL Termination

CA Nimsoft Unified Management Portal

DEPARTMENT OF DEFENSE PUBLIC KEY INFRASTRUCTURE EXTERNAL CERTIFICATION AUTHORITY MASTER TEST PLAN VERSION 1.0

A quick overview of the DANE WG. * DNS-based Authentication of Named Entities

Configuring Digital Certificates

Automated Vulnerability Scan Results

Understanding Digital Certificates on z/os Vanguard Las Vegas, NV Session AST3 June 26th 2012

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

Displaying SSL Certificate and Key Pair Information

Protect your CollabNet TeamForge site

Implementing Secure Sockets Layer on iseries

Certificate Policy and Certification Practice Statement CNRS/CNRS-Projets/Datagrid-fr

Bank link technical specifications. Information for programmers

SSL implementieren aber sicher!

Configuration (X87) SAP Mobile Secure: SAP Afaria 7 SP5 September 2014 English. Building Block Configuration Guide

Acano solution. Certificate Guidelines R1.7. for Single Split Acano Server Deployments. December F

Certificates for computers, Web servers, and Web browser users

User Guide Supplement. S/MIME Support Package for BlackBerry Smartphones BlackBerry Pearl 8100 Series

SSL BEST PRACTICES OVERVIEW

mod_ssl Cryptographic Techniques

Dr. Cunsheng DING HKUST, Hong Kong. Security Protocols. Security Protocols. Cunsheng Ding, HKUST COMP685C

CHAPTER 7 SSL CONFIGURATION AND TESTING

Unifying Information Security. Implementing TLS on the CLEARSWIFT SECURE Gateway

Cisco Expressway Certificate Creation and Use

MINICA: A WEB-BASED CERTIFICATE AUTHORITY. A Project. Presented to the. Faculty of. California State University, San Bernardino

How to configure SSL proxying in Zorp 3 F5

SSL/TLS: The Ugly Truth

Integrated SSL Scanning

How to: Install an SSL certificate

Brocade Engineering. PKI Tutorial. Jim Kleinsteiber. February 6, Page 1

PowerChute TM Network Shutdown Security Features & Deployment

Websense Content Gateway HTTPS Configuration

Key Management and Distribution

Ciphermail S/MIME Setup Guide

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

SSL Configuration Best Practices for SAS Visual Analytics 7.1 Web Applications and SAS LASR Authorization Service

ASA 8.x: Renew and Install the SSL Certificate with ASDM

How to generate SSL certificates for use with a KVM box & XViewer with XCA v0.9.3

SolarWinds Technical Reference

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

SSL Protect your users, start with yourself

Transcription:

SSL/TLS Hands-on Thomas Herlea SecAppDev, 2014-02-12 thomas.herlea@trasysgroup.com Creative Commons Attribution Non-Commercial License

A TLS Stack PEOPLE APPLICATIONS You are here LIBRARIES PROTOCOLS CRYPTO MATH 2014-02-12 2

Disclaimer This hands-on session is focused on security aspects, not Accessibility Performance Portability Efficient maintenance Not even all known security aspects are covered 2014-02-12 3

Structure Today Act I: Let s get a padlock on our web site! In the future Act II: Configure TLS well on the server! Act III: Make the web app play nice with TLS! 2014-02-12 4

Playground (1) Linux: Fedora 20 (http://fedoraproject.org/en/get-fedora) Host name: learn.tls.now User secappdev, password secret We will use the command line: $ user_command <- type as 'user_command' # root_command <- same as 'sudo root_command' We will edit configuration files 2014-02-12 5

Playground (2) Already installed: Apache web server 2.4.6 # yum install httpd # systemctl enable httpd.service The document root is in /var/www/html/, linked from desktop The configuration directory is /etc/httpd Already installed, but inactive: mod_ssl # yum install mod_ssl Already installed: OpenSSL 1.0.1e # yum install openssl 2014-02-12 6

ACT I Let s get a padlock on our web site! 2014-02-12 7

Act I Completion Criteria http://learn.tls.now loads without problems https://learn.tls.now loads without problems 2014-02-12 8

Try It! HTTP woks out of the box HTTPS doesn t work yet 2014-02-12 9

Launch Wireshark Browse the site through http Find the password in the traffic Wireshark 2014-02-12 10

Act I Completion Criteria (2) http://learn.tls.now loads without problems https://learn.tls.now loads without problems No connection error 2014-02-12 11

Enable https "Activate" mod_ssl: # mv /etc/httpd/conf.d/ssl.conf.dead /etc/httpd/conf.d/ssl.conf Tell Apache to reload its configuration # systemctl reload httpd.service Refresh the browser 2014-02-12 12

Try it again! If the user continued: Confidentiality OK Integrity OK Authenticity of the server UNKNOWN If your production site is like this you re teaching your users bad habits! And you are hurting our collective security! 2014-02-12 13

"Technical Details" of Firefox Warning This Connection is Untrusted Technical Details learn.tls.now uses an invalid security certificate. The certificate is not trusted because it is self-signed. 2014-02-12 14

Security Certificate? I did not do anything about certificates! You did not do anything, either! But Fedora did: The mod_ssl installation generated a dummy certificate Why: it gets the server up and running without friction Good for novices, they can learn later to do it properly Neutral for professionals, they are supposed to have a secure procedure anyway Most Linux distros do it this way 2014-02-12 15

Not Trusted? because it is self-signed Misnomer: the trusted Root CA certificates are self-signed, too Should be: because certificate signer is not trusted. For continuing the browser asks the user: Do you trust the certificate signer? When continuing, the user answers Yes Actually, most users just want to answer Get out of my way! Risky - the certificate could belong to an attacker-in-the-middle! The Add exception permanently option makes the risk permanent Lesson: avoid exposing your users to this warning in the first place! 2014-02-12 16

Act I Completion Criteria (3) http://learn.tls.now loads without problems https://learn.tls.now loads without problems No connection error No trust warning 2014-02-12 17

Where is the Certificate? You have already met /etc/httpd/conf.d/ssl.conf In it you can find the directives: # TLS Configuration per virtual host <VirtualHost _default_:443> SSLEngine on SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateKeyFile /etc/pki/tls/private/localhost.key... </VirtualHost> 2014-02-12 18

Crash Course OpenSSL CLI In Fedora 20 the version of OpenSSL is 1.0.1e OpenSSL has a command mode: # openssl SUBCOMMAND OPTIONS Which subcommands? Run man openssl, see the COMMAND SUMMARY section Then run man SUBCOMMAND Options are in single dash format E.g.: -noout, do not re-display raw input Some options can have parameters E.g.: -in INPUTFILE, read input from INPUTFILE, not stdin 2014-02-12 19

# cd /etc/pki/tls/ Inspect Certificate with OpenSSL (1) # openssl x509 -in certs/localhost.crt text -noout Certificate: Data:[ ] Signature Algorithm: sha1withrsaencryption Issuer: C=--, ST=SomeState, [ ] Validity Not Before: Feb 11 09:35:21 2014 GMT Not After : Feb 11 09:35:21 2015 GMT Subject: C=--, ST=SomeState, [ ] Subject Public Key Info: Public Key Algorithm: rsaencryption Public-Key: (1024 bit) Modulus:[ ] Exponent: 65537 (0x10001) 2014-02-12 20

Inspect Certificate with OpenSSL (2) (continued) X509v3 extensions: X509v3 Basic Constraints: CA:FALSE X509v3 Key Usage: Digital Signature, Non Repudiation, Key Encipherment Signature Algorithm: sha1withrsaencryption 2014-02-12 21

Act I Completion Criteria (4) http://learn.tls.now loads without problems https://learn.tls.now loads without problems No connection error No trust warning Private key of at least 2048 bits Public exponent of at least 17 bits Certificate corresponding to the domain Certificate corresponding to private key Signature on certificate valid Certificate signing key is trusted (maybe through recursion) Signature algorithm not using MD5 Validity period of 1 year Usage compatible with being a web site certificate 2014-02-12 22

Steps: We Need to Generate a New Certificate 1. You generate a key pair 2. You generate a Certificate Signing Request (CSR) 3. A Registration Authority verifies the CSR 4. A Certificate Authority creates the certificate for you There are numerous helper tools and wizards Fedora recommends genkey from package crypto-utils Fedora provides OpenSSL GUI package xca Fedora provides heavyweight set of packages pki-* OpenSSL wrapper: /etc/pki/tls/misc/ca OpenSSL subcommand: openssl ca We will take the route that shows a lot of detail 2014-02-12 23

Generate a Keypair Keys will be for RSA (a little simpler than for DSA) Default keyfile format is PEM, accepted by Apache The conventional keypair file extension is.key Key length of at least 2048 bits is based on estimated strength NIST Special Publication 800-57 (July 2012) CA/Browser Forum Baseline Requirements (November 2011) Public exponent of at least 32 bits, because of: 2006: Belichenbacher attack against exponent 3 PKCS #1 v1.5 SecAppDev 2012, Bart Preneel: use >32 bits So far, recommended key generation: # openssl genpkey -algorithm rsa -out private/keys.key -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:0x100000001 2014-02-12 24

Keyfile Protection Option 1: password protect the keyfile Add cipher option, e.g. -aes-128-cbc By default, passphrase provided interactively at generation See man openssl, section PASS PHRASE ARGUMENTS But passphrase must be provided every time Apache starts up See docs for SSLPassPhraseDialog Option 2: keyfile protected at filesystem and SELinux level # chmod u=rw,go= private/keys.key # selinux 2014-02-12 25

Act I Completion Criteria (5) http://learn.tls.now loads without problems https://learn.tls.now loads without problems No connection error No trust warning Private key of at least 2048 bits Public exponent of at least 17 bits Certificate corresponding to the domain Certificate corresponding to private key Signature on certificate valid Certificate signing key is trusted (maybe through recursion) Signature algorithm not using MD5 Validity period of 1 year 2014-02-12 26

The Certificate Signing Request Command: # openssl req -new [OPTIONS] -key private/keys.key -out certreq.csr One-year validity period with -days 365 Default hash algorithm is SHA1, not MD5 Other constraints do not have command line options, but are indicated in a configuration file 2014-02-12 27

OpenSSL Configuration Files Config file can be default or specified with -config CONFIGFILE On Fedora the default file is: /etc/pki/tls/openssl.cnf Sections are introduced by lines like [ section_name ] Section [ v3_req ] has some good values: basicconstraints = CA:FALSE If lost, the private key can not be used to sign other certificates keyusage = nonrepudiation, digitalsignature, keyencipherment Compatible with being a web site certificate Use that section with -extensions v3_req 2014-02-12 28

The Domain Name for the Certificate Express the domain name as a Distinguished Name: -subj "/C=BE/ST=Vlaams Brabant/L=Leuven/O=SecAppDev/CN=learn.tls.now/" What about co-hosting related web sites on the same IP address? https://learn.tls.now:443, but also https://www.tls.now:443 and https://tls.now:443 Same web server, same configuration, cannot serve more than one certificate Specify all names in the [v3_req] section of the configuration file, which the simulated CA will later use: subjectaltname=dns:learn.tls.now,dns:www.tls.now,dns:t ls.now 2014-02-12 29

CSR Generation Summary Generate a CSR (Certificate Signing Request) # openssl req -new -subj "/C=BE/ST=Vlaams Brabant/L=Leuven/O=SecAppDev/CN=learn.tls.now/" -days 365 -extensions v3_req -key /etc/pki/tls/private/keys.key -out /etc/pki/tls/certreq.csr 2014-02-12 30

Trust in the Certificate Between Strangers Anyone can generate a CSR for your web site You need to be able to prove to strangers it s your web site Employ Trusted Third Parties professional Registration Authorities professional Certification Authorities Luckily, browsers come preloaded with trusting a bunch of them Or Unfortunately, (in case one of them is corrupted) Certifying your public key usually has a price tag We will simulate the CA s procedure 2014-02-12 31

Extended Validation Certificates What exactly is certified? It should be: requester s ownership of the FQDN How stringent checks? Verify photo ID of the requester? Verify business ownership of the FQDN? Verify control of the indicated e-mail address? Verify possession of the private key? Don t verify, just issue a limited-time testing cert? Extended Validation certificates a.k.a. the way it should have been done in the first place Validation requirements are no less than a known threshold Certificates contain a reference to the CA s verification policy Current browsers display additional positive assurance for EV certs 2014-02-12 32

Simulated CA Step Sign the Certificate Signing Request Prepare a file to keep track of the serial numbers Prepare a file to keep track of the issued certificates Configure various other values in openssl.conf $ ~/ca/casign /etc/pki/tls/certreq.csr The passphrase for the CA s private key is trustedca The signed certificate will be saved to /etc/pki/tls/certs/casigned.crt 2014-02-12 33

Deploy Certificates to Apache The files are already in the folders expected by Apache on Fedora Therefore they have inherited the correct SELinux context Let mod_ssl know about them Replace old values in /etc/httpd/conf.d/ssl.conf: SSLCertificateFile /etc/pki/tls/certs/casigned.crt SSLCertificateKeyFile /etc/pki/tls/private/keys.key Let Apache know about the change # systemctl reload httpd.service Use systemctl reload, because we just changed configs 2014-02-12 34

It Worked! 2014-02-12 35

Act I Completion Criteria (6) http://learn.tls.now loads without problems https://learn.tls.now loads without problems No connection error No trust warning Private key of at least 2048 bits Public exponent of at least 17 bits Certificate corresponding to the domain Certificate corresponding to private key Signature on certificate valid Certificate signing key is trusted (maybe through recursion) Signature algorithm not using MD5 Validity period of 1 year 2014-02-12 36

Discussion: Certificate Chains There are sub-cas and sub-sub-cas, Browser only knows root CA certificate in the beginning Web site must provide the intermediate links in order: TLS RFC says so: each certificate certifies the one before it -----BEGIN CERTIFICATE----- MIICzzCCAbegAwIBAgIJAIXRQJSXK2HAYD Ap Sub-sub-CA certificate U2olbGhvc3QubG9jYWxkb -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- FLVQQD MIIDCTCCAnKgAwIBAgICNtQwDQYJKoDBVs MR Sub-CA certificate IGS25sSHgrz8OU28eA== -----END CERTIFICATE----- ETb2Nh The cert chain goes into the file specified in ssl.conf SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt 2014-02-12 37

Discussion: Certificate Expiration and Revocation At expiry, assume private key to be compromised Cryptanalysis: deriving it from the public key Breach: breaking into web server and copying the file Brute force 1: trying enough candidates for a match Brute force 2: convince a sysadmin to disclose it Generate a new keypair for every new certificate, it s cheap Reasons for renewing the keypair even before expiration: You have evidence of key compromise (see above) You have lost control of the private key (no disaster recovery) Inform the CA, who updates a CRL or an OCSP server Browsers would ignore the old cert if they encountered it 2014-02-12 38

Bibliography Fedora 18 System Administrator s Guide, Ch. 14, Web Servers: http://docs.fedoraproject.org/en- US/Fedora/18/html/System_Administrators_Guide/ch-Web_Servers.html#s2- apache-mod_ssl Apache 2.4 Module mod_ssl: http://httpd.apache.org/docs/2.4/mod/mod_ssl.htm OpenSSL man pages and HOWTOs: http://www.openssl.org/docs/ OWASP Transport Layer Protection Cheat Sheet: https://www.owasp.org/index.php/transport_layer_protection_cheat_sheet 2014-02-12 39

QUESTIONS? SEE YOU AGAIN AT SECAPPDEV 2014! 2014-02-12 40