Firstly, it's misleading to describe a certificate as “its purpose is to encrypt traffic”. Its purpose is to protect traffic, but not by being the key used to encrypt it.
A certificate comprises (among other things) an asymmetric key pair. Using this key pair to encrypt & decrypt network traffic would be awkward for a variety of technical reasons, but if you managed to jury-rig things to use one of the keys in a certificate to encrypt traffic, you would run up against a more fundamental problem: to be useful as a certificate, one half of its asymmetric key pair has to be made public, and the other half must never be shared. Therefore
As a certificate canresult, your jury-rigged encryption would only protect trafficbe useful in one direction: encrypting traffic with the private half would be pointless (anyone could read it), and traffic encrypted with the public key would only be readable by the end holding the private key.
- traffic encrypted with a public key would only be readable by the end holding the corresponding private key; and conversely
- encrypting traffic with a private key would be pointless (anyone holding the corresponding public key could read it).
SecondlyYou could of course work around this shortcoming by having a separate key pair for each direction, certificates are not used to encrypt traffic; ratherbut nobody does that in practice, they're used to sign symmetricmostly because asymmetric encryption keys that are randomly generated anew for each connection. This is especially useful where two communicating endpointsalgorithms are not under common administrative controlfar more costly than symmetric ones. This
Rather, traffic is done because it's vastly more efficientexchanged over a session protected by a symmetric cipher, and avoids needing separatewhose key pairsis ephemeral - it exists only for the traffic in each directionduration of that session.
Thirdly,The certificate comes into play when proving the identify of (one of) the endpoints; in doing so it offers a secondary proof against a MITM attack.
As for why certificates expire: any certificate or encryption key should generally have a limited lifetime because:
- over time there is an ever-increasing (cumulative) risk that the devices holding a private (or symmetric) key may be compromised (and you can't use a compromised key to distribute its own replacement);
- they may be weakened (or completely defeated) by advances in cryptanalysis;
- an attacker might just get lucky and guess the key; and
- they will eventually be threatened by Moore's Law.
A certificate's lifetime is set such that there's an extremely small chance of any of these happening before it expires. Ephemeral
The same arguments for key apoptosis apply equally to symmetric encryption key and private keys, but ephemeral symmetric encryption keys generally have extremely short lifetimes, usually no more that are many orders of magnitude shorter than certificates, so a few hoursmore significant worry is that encrypted streams might be recorded by an eavesdropped and then decrypted using new cryptanalysis techniques possibly many years later.