Nick wrote:
> Yes, I meant to load a public key that is stored in a PEM file and ASN1
> encoded that I *don't* have the corresponding private key so that I
> could send an encrypted message.
>
> I don't understand though why this is so difficult; sending a message
> without the private key should be a normal thing to do?
"Difficulty" might be a matter of expectations. Passing the file's bytes
into a parser (the encoding/pem call) and then extracting the various
parameters necessary to then actually make use of it (the crypto/x509
call) doesn't seem unreasonable at all.
Maybe a high-level library would abstract all of that into a single call
taking in a file path, but such a library would necessarily be more
special-purpose than what the standard library provides. If such a
library doesn't exist (I don't know), please feel free to make it and
announce it here...or you could ask the language devs whether they'd
accept a merge request to the standard library that contains such a
convenience function.
--Jeff