We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
source: https://community.letsencrypt.org/t/how-to-get-openssl-rsa-private-key-out-of-private-key-json/4658/5
Using a simple go program:
go
$ go get -u gopkg.in/square/go-jose.v2/... $ go run certbot-to-pem.go [path to private_key.json] -----BEGIN RSA PRIVATE KEY----- <snip>
Here is the program (certbot-to-pem.go):
package main import ( "crypto/rsa" "crypto/x509" "encoding/pem" "fmt" "io/ioutil" "os" "reflect" "gopkg.in/square/go-jose.v2" ) func main() { if len(os.Args) != 2 { fmt.Println("Usage: certbot-to-pem path-to-certbot-private_key.json") os.Exit(1) } pkBuf, err := ioutil.ReadFile(os.Args[1]) if err != nil { panic(err) } var k jose.JSONWebKey if err := k.UnmarshalJSON(pkBuf); err != nil { panic(err) } switch p := k.Key.(type) { case *rsa.PrivateKey: fmt.Println(string(pem.EncodeToMemory(&pem.Block{ Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(p), }))) default: panic("Don't know how to deal with " + reflect.TypeOf(p).String()) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
source: https://community.letsencrypt.org/t/how-to-get-openssl-rsa-private-key-out-of-private-key-json/4658/5
solution
Using a simple
go
program:Here is the program (certbot-to-pem.go):
The text was updated successfully, but these errors were encountered: