TomcatCon Apache Tomcat and TLS Mark Thomas TM Introduction TM - - PowerPoint PPT Presentation

tomcatcon apache tomcat and tls mark thomas
SMART_READER_LITE
LIVE PREVIEW

TomcatCon Apache Tomcat and TLS Mark Thomas TM Introduction TM - - PowerPoint PPT Presentation

T M TomcatCon Apache Tomcat and TLS Mark Thomas TM Introduction TM Why This Presentation? L o t s o f q u e s t i o n s a b o u t T L S o n t h e T o m c a t m a i l i n g l i s t s It is clear from the questions many folks dont


slide-1
SLIDE 1

TM TomcatCon Apache Tomcat and TLS Mark Thomas

slide-2
SLIDE 2

TM

Introduction

slide-3
SLIDE 3

TM

Why This Presentation?

  • Lots of questions about TLS on the Tomcat mailing lists
  • It is clear from the questions many folks don’t understand how

TLS works

  • Debugging something you don’t understand is much harder

than debugging something you do understand

  • I’ll use SSL and TLS interchangeably (as do the Tomcat docs)
slide-4
SLIDE 4

TM

Agenda

  • Cryptography basics
  • TLS
  • Configuring Tomcat for TLS
  • Questions
slide-5
SLIDE 5

TM

Cryptography Basics

slide-6
SLIDE 6

TM

Cryptography Basics: Symmetric Encryption

  • Use the same key to encrypt and decrypt

Cipher Text Private Key Plain Text Cipher Text Private Key Plain Text

slide-7
SLIDE 7

TM

Cryptography Basics: Asymmetric Encryption

  • Pair of keys, A and B

If key A is used to encrypt, key B must be used to decrypt

If key B is used to encrypt, key A must be used to decrypt

  • Very difficult to determine one key from the other
  • One key is used as the “Public Key”

This key is made widely available to the general public

  • One key is used as the “Private Key”

This key must be protected

slide-8
SLIDE 8

TM

Cryptography Basics: Asymmetric Encryption

  • Use different keys to encrypt and decrypt

Cipher Text Plain Text Cipher Text Plain Text Private Key Public Key

slide-9
SLIDE 9

TM

Cryptography Basics: Asymmetric Encryption

  • You can use the keys either way around

Cipher Text Plain Text Cipher Text Plain Text Private Key Public Key

slide-10
SLIDE 10

TM

Cryptography Basics: Hash Functions

  • Generate a fingerprint (hash) for the given input
  • A small change in the input results in a large change in the hash
  • Very difficult to generate an input for a given hash

Plain Text Hash Function Hash

slide-11
SLIDE 11

TM

Cryptography Basics: Digital Signatures

  • Proves a document was sent by a particular entity

Plain Text Hash Function Hash Hash Enc. Hash Private Key Plain Text Enc. Hash Digitally Signed

slide-12
SLIDE 12

TM

Cryptography Basics: Digital Signatures

  • Validating a digital signature

Plain Text Hash Function Hash Hash Enc. Hash Public Key Hash

slide-13
SLIDE 13

TM

Cryptography Basics: Digital Signatures

  • If the hashes match then:

The public key decrypted the digital signature

Therefore the private key must have created the digital signature

Therefore the recipient can be certain that the owner of the private key sent the document

  • Determining who owns the private key is the next problem
slide-14
SLIDE 14

TM

Cryptography Basics: Certificates

  • Proves a public key is associated with a given identity

ID Public Key Hash Function Hash Hash Enc. Hash CA Private Key ID Public Key Enc. Hash Cert- ificate

slide-15
SLIDE 15

TM

Cryptography Basics: Certificates

  • To validate the Certificate Authority’s signature, you need to be

able to link their public key to their identify

  • You do this with a certificate too
  • This builds a trust chain
  • At the top of the chain is the root certificate from a root

certificate authority

  • There are multiple root certificate authorities
slide-16
SLIDE 16

TM

Cryptography Basics: Root Certificates

  • Root certificates are self-signed
  • Some other mechanism is required to trust root certificates

Usually installed by the operating system

You can manually validate them by checking them against the published versions on the CA’s web site My Cert. Signed By My Cert. Signed By My Cert. Signed By Root CA Cert. Self Signed

slide-17
SLIDE 17

TM

TLS

slide-18
SLIDE 18

TM

TLS

  • TLS connections are initiated by a handshake
  • Handshake

Mandatory steps

Optional steps

  • This section considers the common case
slide-19
SLIDE 19

TM

TLS: Handshake Starting Point

  • Server

Private key

Certificate

  • Public Key
  • ID (domain name)

List of supported algorithms

  • Client

List of trusted (Root) CAs

List of supported algorithms

CA

f(x)

S fs() fc()

slide-20
SLIDE 20

TM

TLS: Handshake Step 1: ClientHello

  • Client generates random

number

  • Client sends message to

server

Client’s random number

Client’s supported algorithms

CA

f(x)

S fs() fc() Rc

slide-21
SLIDE 21

TM

TLS: Handshake Step 2: ServerHello

  • Server generates random

number

  • Server compares algorithms

Selects appropriate algorithms

  • Server sends message to

client

Server’s random number

Selected algorithms

CA

f(x)

S fs() fc() Rc

f(x)

fc() Rc RS fA() fs()

slide-22
SLIDE 22

TM

TLS: Handshake Step 3: Certificate

  • Server sends message to

client

Server’s certificate

  • Client validates server

certificate

CA

f(x)

S fs() fc() Rc

f(x)

fc() Rc RS fA() fs() RS fA()

slide-23
SLIDE 23

TM

TLS: Handshake Step 6: ServerHelloDone

  • Server sends message to

client

No content

CA

f(x)

S fs() fc() Rc

f(x)

fc() Rc RS fA() fs() RS fA() S

slide-24
SLIDE 24

TM

TLS: Handshake Step 8: ClientKeyExchange

  • Client generates pre-master

secret

  • Client encrypts PMS with

server’s public key

  • Client sends message to

server

Encrypted PMS

CA

f(x)

S fs() fc() Rc

f(x)

fc() Rc RS fA() fs() RS fA()

PMS enc PMS

S

slide-25
SLIDE 25

TM

TLS: Handshake Step 10: ChangeCipherSpec

  • Client creates master secret

Rc + Rs + PMS

  • Cilent switches to encrypted mode

Algorithm agreed in step 2

Symmetric encryption with MS

  • Client sends message to server

No content CA

f(x)

S fs() fc() Rc

f(x)

fc() Rc RS fA() fs() RS fA()

PMS enc PMS enc PMS

S

MS

slide-26
SLIDE 26

TM

TLS: Handshake Step 11: Finished

  • Client has completed TLS

handshake

  • Client sends message to

server

No content

CA

f(x)

S fs() fc() Rc

f(x)

fc() Rc RS fA() fs() RS fA()

PMS enc PMS enc PMS MS

S

slide-27
SLIDE 27

TM

TLS: Handshake Step 12: ChangeCipherSpec

  • Server decrypts PMS
  • Server creates master secret

Rc + Rs + PMS

Server switches to encrypted mode

Algorithm agreed in step 2

Symmetric encryption with MS

  • Server sends message to client

No content CA

f(x)

S fs() fc() Rc

f(x)

fc() Rc RS fA() fs() RS fA()

PMS enc PMS enc PMS MS PMS MS

S

slide-28
SLIDE 28

TM

TLS: Handshake Step 13: Finished

  • Server has completed TLS

handshake

  • Server sends message to

client

No content

CA

f(x)

S fs() fc() Rc

f(x)

fc() Rc RS fA() fs() RS fA()

PMS enc PMS enc PMS MS PMS MS

S

slide-29
SLIDE 29

TM

TLS: Encrypted Communication

  • Algorithm agreed in step 2
  • Symmetric
  • Use Master Secret as key

CA

f(x)

S fs() fc() Rc

f(x)

fc() Rc RS fA() fs() RS fA()

PMS enc PMS enc PMS MS PMS MS

S

slide-30
SLIDE 30

TM

TLS: Extensions

  • Client certificate authentication

Client authenticates to server with a certificate

  • Server Name Indication

Client tells server which host is wants to connect to and server sends appropriate certificate (virtual hosting)

  • Application Layer Protocol Negotiation

Client and server agree protocol to for encrypted communication during handshake

CA

f(x)

S fs() fc() Rc

f(x)

fc() Rc RS fA() fs() RS fA()

PMS enc PMS enc PMS MS PMS MS

S

slide-31
SLIDE 31

TM

Configuring Tomcat for TLS

slide-32
SLIDE 32

TM

Requirements

  • Private key
  • Server certificate
  • Certificate chain
  • Configuration in server.xml
slide-33
SLIDE 33

TM

File Formats

  • .pem / .crt / .cer / .key

ASCII

Key, certificate or chain

  • .der

Binary form of .pem

  • .p7b (PKCS7)

ASCII

Cert and chain only

  • .p12 (PKCS12)

Binary

Key, cert or chain

  • .jks / .keystore

Binary

Java specific

Key, cert or chain

slide-34
SLIDE 34

TM

Which Format Do I Need?

  • It depends…
  • Tomcat 7 or 8, BIO or NIO

JSSE implementation, JSSE configuration

Keystore

PKCS12 with Java 7+

  • Tomcat 7 or 8 APR/native

OpenSSL implementation, OpenSSL configuration

PEM

slide-35
SLIDE 35

TM

Which Format Do I Need?

  • Tomcat 8.5 and 9, NIO and NIO2

KeyStore, PKCS12 or PEM

JSSE or OpenSSL for configuration

JSSE or OpenSSL for implementation

Can’t mix JSSE and OpenSSL attributes in a single configuration

  • Tomcat 8.5 and 9, APR/native

PEM

OpenSSL implementation and OpenSSL configuration

slide-36
SLIDE 36

TM

Tomcat 7 or 8: BIO or NIO

<Connector protocol="org.apache.coyote.http11.Http11NioProtocol" port="8443" SSLEnabled="true" scheme="https" secure="true" sslProtocol="TLS" keystoreFile="${catalina.base}/conf/localhost.jks" keystorePass="changeit" />

slide-37
SLIDE 37

TM

Tomcat 7 or 8: APR/native

<Connector protocol="org.apache.coyote.http11.Http11AprProtocol" port="8443" maxThreads="200" SSLEnabled="true" scheme="https" secure="true" SSLProtocol="TLSv1+TLSv1.1+TLSv1.2" SSLCertificateFile="/usr/local/ssl/server.crt" SSLCertificateKeyFile="/usr/local/ssl/server.pem" SSLVerifyClient="optional" />

slide-38
SLIDE 38

TM

Changes in Tomcat 8.5

  • Tomcat 7 / Tomcat 8

1 Connector, 1 Hostname, 1 certificate

  • Tomcat 8.5 / Tomcat 9

1 Connector, 1 or more Hostnames

1 Hostname, 1 or more certificates (different types)

  • Tomcat 8 style configuration is supported but deprecated

Connector level attributes are equivalent to the default TLS Host

slide-39
SLIDE 39

TM

Tomcat 8.5 onwards: NIO or NIO2

<Connector protocol="org.apache.coyote.http11.Http11NioProtocol" port="8443" maxThreads="150" SSLEnabled="true"> <SSLHostConfig> <Certificate certificateKeystoreFile="conf/localhost-rsa.jks" type="RSA" /> </SSLHostConfig> </Connector>

slide-40
SLIDE 40

TM

Tomcat 8.5 onwards: APR/Native

<Connector protocol="org.apache.coyote.http11.Http11AprProtocol" port="8443" maxThreads="150" SSLEnabled="true"> <SSLHostConfig> <Certificate certificateKeystoreFile="conf/localhost-rsa.jks" type="RSA" /> </SSLHostConfig> </Connector>

slide-41
SLIDE 41

TM

Questions