Skip to content

Instantly share code, notes, and snippets.

@weppos

weppos/matcher.go

Created Dec 7, 2013
Embed
What would you like to do?
package main
import (
"fmt"
"io/ioutil"
"os/exec"
"strings"
)
func opensslModulus(command string, content string) (string, error) {
cmd := exec.Command("openssl", command, "-noout", "-modulus")
cmd.Stdin = strings.NewReader(content)
out, err := cmd.Output()
if err != nil {
return "", err
}
return string(out), nil
}
func main() {
crt, err := ioutil.ReadFile("server.crt")
if err != nil {
panic(err)
}
key, err := ioutil.ReadFile("server.key")
if err != nil {
panic(err)
}
mkey, err := opensslModulus("x509", string(crt))
if err != nil {
panic(err)
}
mcrt, err := opensslModulus("rsa", string(key))
if err != nil {
panic(err)
}
fmt.Println(string(mkey))
fmt.Println(string(mcrt))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.