certificate icon indicating copy to clipboard operation
certificate copied to clipboard

PEM <-> DER conversion support for other keys in addition to certificates

Open Ayesh opened this issue 7 years ago • 0 comments

Cont. from https://github.com/Ayesh/acme-client/commit/5541a2927f59c6a33bad387992f19af61669b7a9#commitcomment-21383572

Can we make Certificate::pemToDer and Certificate::derToPem methods support public keys, private keys, PGP keys, certificate requests, etc please?

The derToPem method can be a bit troublesome to work because we need to know the correct footer and header, but stripping out them to convert to DER format should be pretty easy.

AFAIK, the headers always follow the pattern BEGIN $something where we have CERTIFICATE, PUBLIC KEY, PRIVATE KEY, and CERTIFICATE REQUEST. If supporting all types is not a good idea, perhaps we can expose additional arguments to \Kelunik\Acme\KeyPair::getPrivate and \Kelunik\Acme\KeyPair::getPublic to specify the desired format (currently returning PEM).

Thanks Niklas. I'm available to lend a hand if possible :)

Ayesh avatar Mar 18 '17 14:03 Ayesh