Automatic replacement of certificates and key pairs