add cert/priv key signature checker

merge-requests/2/merge
Matthew 2019-12-30 17:59:07 -05:00
parent d464d3fa1c
commit 2e88d68301
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
package main
import (
"fmt"
"encoding/json"
"crypto/tls"
"os"
)
// ReturnValue the struct for what the JSON should return
type ReturnValue struct {
Ok bool `json:"ok"`
Message string `json:"message"`
}
func main() {
_, err := tls.LoadX509KeyPair(os.Args[1], os.Args[2])
if err != nil && err.Error() == "tls: private key does not match public key" {
json, _ := json.Marshal(&ReturnValue{Ok: false, Message: "PUBLIC KEY DOES NOT MATCH PRIVATE KEY"})
fmt.Printf("%s", string(json))
return
} else if err != nil {
panic(err)
} else {
json, _ := json.Marshal(&ReturnValue{Ok: true, Message: "PUBLIC KEY MATCHES PRIVATE KEY"})
fmt.Printf("%s", string(json))
}
}