Extracting the public key from the private key
up vote
1
down vote
favorite
I trying to accomplish step (2) in the following way programmatically:
1. openssl genrsa -out signing.pem 2048
2. openssl rsa -in signing.pem -outform PEM -pubout -out signing.pub.pem
Following is a simple function which reads the private key and tries to extract the public key.
But, I am facing difficulty in matching the 2nd step, as the programmatically generated public key is different from the openssl CLI based public key, I am sure there must some mistake, Please, help me.
Thanks
func main()
IN case anyone wants to check the code and play around then here's the link:
https://play.golang.org/p/rKerkh-31KI
ssl
add a comment |
up vote
1
down vote
favorite
I trying to accomplish step (2) in the following way programmatically:
1. openssl genrsa -out signing.pem 2048
2. openssl rsa -in signing.pem -outform PEM -pubout -out signing.pub.pem
Following is a simple function which reads the private key and tries to extract the public key.
But, I am facing difficulty in matching the 2nd step, as the programmatically generated public key is different from the openssl CLI based public key, I am sure there must some mistake, Please, help me.
Thanks
func main()
IN case anyone wants to check the code and play around then here's the link:
https://play.golang.org/p/rKerkh-31KI
ssl
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I trying to accomplish step (2) in the following way programmatically:
1. openssl genrsa -out signing.pem 2048
2. openssl rsa -in signing.pem -outform PEM -pubout -out signing.pub.pem
Following is a simple function which reads the private key and tries to extract the public key.
But, I am facing difficulty in matching the 2nd step, as the programmatically generated public key is different from the openssl CLI based public key, I am sure there must some mistake, Please, help me.
Thanks
func main()
IN case anyone wants to check the code and play around then here's the link:
https://play.golang.org/p/rKerkh-31KI
ssl
I trying to accomplish step (2) in the following way programmatically:
1. openssl genrsa -out signing.pem 2048
2. openssl rsa -in signing.pem -outform PEM -pubout -out signing.pub.pem
Following is a simple function which reads the private key and tries to extract the public key.
But, I am facing difficulty in matching the 2nd step, as the programmatically generated public key is different from the openssl CLI based public key, I am sure there must some mistake, Please, help me.
Thanks
func main()
IN case anyone wants to check the code and play around then here's the link:
https://play.golang.org/p/rKerkh-31KI
ssl
ssl
edited Nov 9 at 8:02
Flimzy
36.8k96496
36.8k96496
asked Nov 9 at 6:56
Invictus
97851536
97851536
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Use MarshalPKIXPublicKey
publicKeyDer, err := x509.MarshalPKIXPublicKey(&key.PublicKey)
if err != nil
log.Fatal(err)
Instead of
publicKeyDer := x509.MarshalPKCS1PublicKey(&key.PublicKey)
Playground
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Use MarshalPKIXPublicKey
publicKeyDer, err := x509.MarshalPKIXPublicKey(&key.PublicKey)
if err != nil
log.Fatal(err)
Instead of
publicKeyDer := x509.MarshalPKCS1PublicKey(&key.PublicKey)
Playground
add a comment |
up vote
2
down vote
accepted
Use MarshalPKIXPublicKey
publicKeyDer, err := x509.MarshalPKIXPublicKey(&key.PublicKey)
if err != nil
log.Fatal(err)
Instead of
publicKeyDer := x509.MarshalPKCS1PublicKey(&key.PublicKey)
Playground
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Use MarshalPKIXPublicKey
publicKeyDer, err := x509.MarshalPKIXPublicKey(&key.PublicKey)
if err != nil
log.Fatal(err)
Instead of
publicKeyDer := x509.MarshalPKCS1PublicKey(&key.PublicKey)
Playground
Use MarshalPKIXPublicKey
publicKeyDer, err := x509.MarshalPKIXPublicKey(&key.PublicKey)
if err != nil
log.Fatal(err)
Instead of
publicKeyDer := x509.MarshalPKCS1PublicKey(&key.PublicKey)
Playground
answered Nov 9 at 7:41
ssemilla
2,762423
2,762423
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53221108%2fextracting-the-public-key-from-the-private-key%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown