Re: Encrypt existing PEM keyfile

"'David von Oheimb' via openssl-users" <[email protected]>
Newsgroups gmane.comp.encryption.openssl.user
Message-ID <[email protected]>
On 26.09.24 02:42, Robert Moskowitz wrote:
> openssl pkey -in testprv.pem -aes128 -out testoprv.pem
>
> And with the command line, you cannot overwrite the in file.  I tried.  :)

This is due to a pretty silly oversight:
for no good reason, the tool opens the output file before reading the 
input file, truncating it to zero length.
Took less than a minute to detect and fix: 
https://github.com/openssl/openssl/pull/25552


> On 9/25/24 05:49, Robert Moskowitz wrote:
>> ARGH!!!  :)
>>
>> Like I said, my search foo is weak.
>>
>> And I use "openssl pkey" often enough to display the PEM content.
>>
>> Sigh.    Thanks.

Welcome.

BTW, regarding the OpenSSL C API, looking at the respective openssl app 
implementation usually provides hints which functions to use
(while the structure of the code of many those apps can be rather messy 
and useful functions may be hard to find).

In this case, apps/pkey.c directly reveals PEM_write_bio_PrivateKey().
For reading private keys, things are handled in a more general and much 
more complicated fashion in apps/lib/apps.c.
Yet as one might guess, there are similarly simple functions like 
PEM_write_PrivateKey().

     David


-- 
You received this message because you are subscribed to the Google Groups "openssl-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openssl-users+unsubscribe-MCmKBN63+Bmbup2nOX2J7Q@public.gmane.org
To view this discussion on the web visit https://groups.google.com/a/openssl.org/d/msgid/openssl-users/fa368036-cc1f-4e83-94a2-e2ee5f371749%40von-Oheimb.de.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.