I have an Encrypted Private Key(say,servenc.key) in below format:
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIC2TBTBgkqhkiG9w0BBQ0wRjAlBgkqhkiG9w0BBQwwGAQSIFFvMaBFyBvqqhY6
yTV2fMVVAgIUczAdBglghkgBZQMEASoEEGRetyFtHhnJ7TZTM2qolWkEggKAFg/h
GERtM1loEd+u8VAtLwTzBiXE5pmRpp/hX/1HrbBnzFjAsNtWlEtzpSuxuCoXtMst
uKRB8qveHlfTQPzopkRZtljfOkD1DhdJz8BXSZrFmVkMrUq6m4Y/rnqTqI5JmtmQ
qAXTBbl7u8TwMnqIaoSInEHnc+aiFT3KJuIq6PZy2rGKWGW2WB/OML2gANvHBI9n
gyOo4VZHNsR6VBbCRJErUFhF5Wk2/YJD9ejnvXH6pJFqZYvnCFjkSlR+4MdCHBSo
Ld0IoFjQ6X1uLLglFf/rQGKEQruLjTKmz6oe8nZIzrOoLmArir0DGTakEt0K6mha
0M5s9zNkdMd7XRns0uvmYHzbpNVWpUP5YUmf1BJLjTHex51Msjoz6v6ixinel852
5lS2wtVwXp8MXG9iofvMEDocmvn60vuksmgwxMccRWX2zAt8ixFefzIjM0KzPRpt
ByJP0B733u+DI0Y5bsiJVAxl7Gr8Io5k6Uk0nZziVK8+vDXLF2BNetp4kRM/XBaM
N/DcosGiAxOeJqSA45ethV8cHGZVuNOsCXSVomVoKIxgWhkyBzXv9sIbRSSGWfJQ
edWEV9t4RTCgIu+622JZFzw1PbWtEu4R38v0JZQN3zxkYPC7nFIfmx9unUWucoup
ZYbvlzjyNZ6VI8jDvvqy+XmaY+FZcSgPTGCz/4KArxJuSvE8gJULUS7Y7JCuDjjL
h04pYsl8WMA3UH2/CxiFv75vXZI0q2HKUnNNawrQG83zPfBiVrDQARifCkPmzsCd
tHd8A/agDAeg9rmat6PRC4d0to6pUg7v5ZR9VZkRWMJiPMtuH4fh/2L/ys/9EihG
CZJe6XTZkgFAp9gzGg==
-----END ENCRYPTED PRIVATE KEY-----
TH above key is in PKCS#8 format.
I want to convert it into a RSA Private Key PKCS#1 format
The command I use is:
openssl rsa -in servenc.key -out serv.key
The output which i get is in the below format:
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDymMsf+68EERSkXO7lwucBa5Ibw+74z+dL/yYWsHxsl+j9E3ZK
5hQ9riiDxscTd+Jm6aqYF5Dobsk+VWoz7Ma+4iLvHiLevefRxlq7Fpe70vRZeNR5
Z+9cLaak4C4/FYrUoOrMjfHxX0Ihmc5M+Tjy4brxpktCTRRm73CyMxT7twIDAQAB
AoGBAOXc8rJWVqmiyY1HZTEdMKb+1w0p5Leqvr0agGuFRA/dDG0nULF9OfaLm2Xp
Jd4DfOkIRJUh1zL1Lge7BQs4McL529nbKirlstUDvR+dRYoyhCNCnVNqKgU/P+Ed
1wEOhVxOLKfcv847huDzzBU7ZL8E3QEQUd9t3CLj3Ov/c2C5AkEA+ks6fX0GXWht
D6IHW+XBEW4txkfm2WWI64RG8Y0avjg9P1vhw/APlCuZPRmsXQ6S9/wKJt/iy0ah
eJVJ3f1/3QJBAPggpLsU7H/0PKCmC8HUrnWG7ANIiZJYib5LJWAnCzpxNNMNmY5Z
0Ak18/ia4bloNz/g9QXIa7kuG9+lSGF+uqMCQBfcpC7ihIDTO9KJt/ni5Y0r2+FT
aYbAT1Vkvv64XRxVcEFiGRv8/v85SNqyX+RfR1OtC6q5HX4TtcExOmGXkWECQQCd
lW3JexJweRcAGDSjV4WtEpFVzH3CugRRHLySAnn5FeismZiKdbPQBbn6i7ML44oj
QaWblJwFsaj2Mqxzbt7tAkB2dxlU+ABHDJ2wvGzECecYPvDeIIcuN1VyZvnYcPek
uehkYsNKd45pNxZr0ZZN1UlVht7kBZWX/+Ij2ezShYDA
-----END RSA PRIVATE KEY-----
But the output format which I want is:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,4D58B420357E8F3A5528539062B3CE0A
hfuamWEa7FijcPBoYuyRxHF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j5y7fNy9px0
PsS2Q3X+Yq2tqJeVqfkGQtseck9DvMo+4OkCQ0jgEvAKNusIkGG5evWHnto1Fl54
rfuSuHhoanSsMdYmxEVQZnszJfaqr/Bb5d9xCMxvvAFwakip9JZrQNuBSlTiUyw0
rKxvovwRhUlemYX9I+UNJeHpUyQAa4Ky1twfrwZ47vAPreCrQrcAAomkx+QLmxjl
coi48GkWKtbr2mQwhjDoiNWW2F7ZzuX0FVheaay9QlyHlFeDcezxcae44k+eD7jc
FmqH05uQrrlBPQLG5brhqZdhq0skwWwIMeA7yW0oEXmoQ5fyRChgXxiXeYcEblhV
PaBJnVM81Rgrvsys3TdgCHgtUIlJDm+gEp6s8X3yhls8aqXN7R65j9jzXLIzYO40
0tLoistWlRQ5G7MCDgazw/hkIiRaEhSuZZs+e6fa4zyxYYq/UenMpAst7+YyXon2
4nSYd88OEvhpAaoCfQomUdIxjcLsZoheJc19RMv/LHy2stL8ZAFyT62HqOCIhH+A
-----END RSA PRIVATE KEY-----
How do I get the below information as well while converting a key from PKCS#8 format to PKCS#1 format?
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,4D58B420357E8F3A5528539062B3CE0A
You just need to add an encryption mechanism, e.g., -des3
openssl pkey -in servenc.key -out serv.key -des3