mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 18:35:51 +02:00
enhance: show the info of changed certificates #386
This commit is contained in:
parent
e1a5521f4a
commit
2d6fa63964
16 changed files with 1760 additions and 1644 deletions
|
@ -17,21 +17,18 @@ type Info struct {
|
|||
|
||||
func GetCertInfo(sslCertificatePath string) (info *Info, err error) {
|
||||
certData, err := os.ReadFile(sslCertificatePath)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "error read certificate")
|
||||
return
|
||||
}
|
||||
|
||||
block, _ := pem.Decode(certData)
|
||||
|
||||
if block == nil || block.Type != "CERTIFICATE" {
|
||||
err = errors.New("certificate decoding error")
|
||||
return
|
||||
}
|
||||
|
||||
cert, err := x509.ParseCertificate(block.Bytes)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "certificate parsing error")
|
||||
return
|
||||
|
@ -43,6 +40,5 @@ func GetCertInfo(sslCertificatePath string) (info *Info, err error) {
|
|||
NotAfter: cert.NotAfter,
|
||||
NotBefore: cert.NotBefore,
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue