2
votes

I am working with a WCF service with mutual SSL security and I want to check my understanding of what certificate is used when.

Is this correct?

  1. Client hands the server the client public certificate

  2. Server hands the client the server public certificate

  3. Client sends request encrypted using the server public certificate

  4. Server decrypts request using the server private certificate

  5. Server sends response encrypted using the client public certificate

  6. Client decrypts response using the client private certificate

Or does it work in some other way?

WCF Mutual SSL Certs

1
RFC 2246 Section 7.4 details the handshake pretty nicely: tools.ietf.org/html/rfc2246 .jglouie
If you can summarise that into an answer I'll give you some points ;)Fenton

1 Answers

4
votes

RFC 2246, Section 7.4 details the handshake. Other versions of SSL/TLS work pretty similarly with regards to your question.

SSL/TLS involves two types of encryption. Asymmetric-key encryption and Symmetric-key encryption. The certificates are used for asymmetric-key encryption, and are used solely in the handshake process.

The encryption used by the certificates is very brief in time, used in the handshake. The server public/private key pair (asymmetric keys) is used to protect the session key (symmetric key). The client public/private key pair is used to prove to the server that the client is who it says it is. It knows this because the client is able to encrypt data (data known by both sides) using the client private key (that only it knows) and the server may decrypt it using the client public key.

For the ordering, I've bolded the parts of your question in the summary list below. Here's a nice summary from MSDN:

The TLS Handshake Protocol involves the following steps:

  1. The client sends a "Client hello" message to the server, along with the client's random value and supported cipher suites.
  2. The server responds by sending a "Server hello" message to the client, along with the server's random value.
  3. The server sends its certificate to the client for authentication and may request a certificate from the client. The server sends the "Server hello done" message.
  4. If the server has requested a certificate from the client, the client sends it.
  5. The client creates a random Pre-Master Secret and encrypts it with the public key from the server's certificate, sending the encrypted Pre-Master Secret to the server.
  6. The server receives the Pre-Master Secret. The server and client each generate the Master Secret and session keys based on the Pre-Master Secret.
  7. The client sends "Change cipher spec" notification to server to indicate that the client will start using the new session keys for hashing and encrypting messages. Client also sends "Client finished" message.
  8. Server receives "Change cipher spec" and switches its record layer security state to symmetric encryption using the session keys. Server sends "Server finished" message to the client.
  9. Client and server can now exchange application data over the secured channel they have established. All messages sent from client to server and from server to client are encrypted using session key.

The WCF request/responses will all be after the client/server have switched to using the session key (symmetric key) for encryption. It won't be using the certificate private/public keys at this point.