2019-02-22 17:35:49 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2019-10-16 11:09:29 +02:00
|
|
|
"forge.cadoles.com/Cadoles/go-http-peering/crypto"
|
2022-09-12 17:46:59 +02:00
|
|
|
"github.com/pkg/errors"
|
2019-02-22 17:35:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func createKey() {
|
|
|
|
passphrase, err := getPassphrase()
|
|
|
|
if err != nil {
|
2022-09-12 17:46:59 +02:00
|
|
|
handleError(errors.WithStack(err))
|
2019-02-22 17:35:49 +01:00
|
|
|
}
|
|
|
|
key, err := crypto.CreateRSAKey(keySize)
|
|
|
|
if err != nil {
|
2022-09-12 17:46:59 +02:00
|
|
|
handleError(errors.WithStack(err))
|
2019-02-22 17:35:49 +01:00
|
|
|
}
|
|
|
|
privatePEM, err := crypto.EncodePrivateKeyToEncryptedPEM(key, passphrase)
|
|
|
|
if err != nil {
|
2022-09-12 17:46:59 +02:00
|
|
|
handleError(errors.WithStack(err))
|
2019-02-22 17:35:49 +01:00
|
|
|
}
|
|
|
|
fmt.Print(string(privatePEM))
|
|
|
|
}
|