Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert pkcs8 to pkcs1 using openssl native

We provide only pkcs8 keys, if you cannot use pkcs8 you can use the pkcs1 encoding, use openssl to convert

The following command was tested on the version 2.6.5

$ openssl version
LibreSSL 2.6.5

When prompet to enter password, don't enter a password, just press the enter or return key on you keyboard

$ openssl pkcs8 -in pkcs1_pk.pem -out pkcs1_pk.pem
Enter Password:

For this private key the result is has follows

$ cat pkcs1_pk.pem
-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALmYoeLlTMrJeN5m
q8eSvsWT8L0NP0OrEN43aDEX24fKotxgVNSXNX3ykouzhYM+lloexKjuEPCkkIU/
II5edGBCDwoZWuoelK/7MlZzc+2137PzpXgoFBaNEC2J9vmaDt90FfOvMzBJn2p8
Lq6mf5MPW90tbMv0jgacYTOgb8u1AgMBAAECgYEAlLgEyM7bCQgGTZhR//rL2YCh
gKvzzOJwAtC9MdGfPSGX/SVH9I4x8/mDimRREQj+67oJ9h/F/T6w+8TI7qwrbXVE
rw2avr+9CM4TLbQIEEnu14NZ+voRsz3kRFpk3vNsLzXhe7jRLws+UCKX4mQRUbf+
On2YjYC3D0btfC2mO8ECQQDc6beJvYlICs67wvojwPskxItZAep3crDmaSpIv+VR
BPUmpB7GhQS9/NUJOl4WacEPdgLEOefOtLjD0mTs0IvRAkEA1xLxZSbA00iFU/y7
FgvBSZoXXuaUkWxvjb6cRDyHD5zqo3jBfbpN3KhJE3d7H/seAYQ85He0D8DmoISx
E6xOpQJAYqdQ2oc1DmIdLoaFFIBy51mKbUZIwe0LCOqAApsHumW/YPE7+SWgF4QY
UxWovNOfbtshoyXE2m+kb3a+sW70cQJAXru+TmKyfp4r9CGXOo+09LmF38xK1n9f
55x08m2CxDLG+3heKgYc87vAbG2tcxnGTr6zn6LGUkYSj9PCt7qm7QJAPPk6R44M
BOlTkDuh2yghowlrEZqtE74VW/VsnMmb9UB+5LnoK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W5C5BPO/qM=
-----END ENCRYPTED PRIVATE KEY-----
@Bagwell80

This comment has been minimized.

Copy link

@Bagwell80 Bagwell80 commented Jan 10, 2021

We provide only pkcs8 keys, if you cannot use pkcs8 you can use the pkcs1 encoding, use openssl to convert

The following command was tested on the version 2.6.5

$ openssl version
LibreSSL 2.6.5

When prompet to enter password, don't enter a password, just press the enter or return key on you keyboard

$ openssl pkcs8 -in pkcs1_pk.pem -out pkcs1_pk.pem
Enter Password:

For this private key the result is has follows

$ cat pkcs1_pk.pem
-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALmYoeLlTMrJeN5m
q8eSvsWT8L0NP0OrEN43aDEX24fKotxgVNSXNX3ykouzhYM+lloexKjuEPCkkIU/
II5edGBCDwoZWuoelK/7MlZzc+2137PzpXgoFBaNEC2J9vmaDt90FfOvMzBJn2p8
Lq6mf5MPW90tbMv0jgacYTOgb8u1AgMBAAECgYEAlLgEyM7bCQgGTZhR//rL2YCh
gKvzzOJwAtC9MdGfPSGX/SVH9I4x8/mDimRREQj+67oJ9h/F/T6w+8TI7qwrbXVE
rw2avr+9CM4TLbQIEEnu14NZ+voRsz3kRFpk3vNsLzXhe7jRLws+UCKX4mQRUbf+
On2YjYC3D0btfC2mO8ECQQDc6beJvYlICs67wvojwPskxItZAep3crDmaSpIv+VR
BPUmpB7GhQS9/NUJOl4WacEPdgLEOefOtLjD0mTs0IvRAkEA1xLxZSbA00iFU/y7
FgvBSZoXXuaUkWxvjb6cRDyHD5zqo3jBfbpN3KhJE3d7H/seAYQ85He0D8DmoISx
E6xOpQJAYqdQ2oc1DmIdLoaFFIBy51mKbUZIwe0LCOqAApsHumW/YPE7+SWgF4QY
UxWovNOfbtshoyXE2m+kb3a+sW70cQJAXru+TmKyfp4r9CGXOo+09LmF38xK1n9f
55x08m2CxDLG+3heKgYc87vAbG2tcxnGTr6zn6LGUkYSj9PCt7qm7QJAPPk6R44M
BOlTkDuh2yghowlrEZqtE74VW/VsnMmb9UB+5LnoKQrlF4eJ4LE2af8IshfTAQ5G
6gdpFxpyHxfNfw==
-----END PRIVATE KEY-----
@Bagwell80

This comment has been minimized.

Copy link

@Bagwell80 Bagwell80 commented Jan 10, 2021

True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment