go-http-peering/cmd/keygen/create_key.go

25 lines
487 B
Go

package main
import (
"fmt"
"forge.cadoles.com/Cadoles/go-http-peering/crypto"
"github.com/pkg/errors"
)
func createKey() {
passphrase, err := getPassphrase()
if err != nil {
handleError(errors.WithStack(err))
}
key, err := crypto.CreateRSAKey(keySize)
if err != nil {
handleError(errors.WithStack(err))
}
privatePEM, err := crypto.EncodePrivateKeyToEncryptedPEM(key, passphrase)
if err != nil {
handleError(errors.WithStack(err))
}
fmt.Print(string(privatePEM))
}