// the certificate has been deleted from disk or is otherwise corrupt
ifnow.After(lastCertAvailable.Add(exitAfter)){
ifclientCertificateManager.ServerHealthy(){
glog.Fatalf("It has been %s since a valid client cert was found and the server is responsive, exiting.",exitAfter)
}else{
glog.Errorf("It has been %s since a valid client cert was found, but the server is not responsive. A restart may be necessary to retrieve new initial credentials.",exitAfter)
lastCertAvailable:=time.Now()
lastCert:=clientCertificateManager.Current()
gowait.Until(func(){
curr:=clientCertificateManager.Current()
ifexitAfter>0{
now:=time.Now()
ifcurr==nil{
// the certificate has been deleted from disk or is otherwise corrupt
ifnow.After(lastCertAvailable.Add(exitAfter)){
ifclientCertificateManager.ServerHealthy(){
glog.Fatalf("It has been %s since a valid client cert was found and the server is responsive, exiting.",exitAfter)
}else{
glog.Errorf("It has been %s since a valid client cert was found, but the server is not responsive. A restart may be necessary to retrieve new initial credentials.",exitAfter)
}
}
}
}else{
// the certificate is expired
ifnow.After(curr.Leaf.NotAfter){
ifclientCertificateManager.ServerHealthy(){
glog.Fatalf("The currently active client certificate has expired and the server is responsive, exiting.")
}else{
glog.Errorf("The currently active client certificate has expired, but the server is not responsive. A restart may be necessary to retrieve new initial credentials.")
}else{
// the certificate is expired
ifnow.After(curr.Leaf.NotAfter){
ifclientCertificateManager.ServerHealthy(){
glog.Fatalf("The currently active client certificate has expired and the server is responsive, exiting.")
}else{
glog.Errorf("The currently active client certificate has expired, but the server is not responsive. A restart may be necessary to retrieve new initial credentials.")
}
}
lastCertAvailable=now
}
lastCertAvailable=now
}
}
ifcurr==nil||lastCert==curr{
// Cert hasn't been rotated.
return
}
lastCert=curr
glog.Infof("certificate rotation detected, shutting down client connections to start using new credentials")
// The cert has been rotated. Close all existing connections to force the client