Hello,
I need help working with a public key and a certificate signature.
My Input:
-
I have a public key in this format:
-----BEGIN PUBLIC KEY----- MDYwEAYHKoZIzj0CAQYFK4EEAAoDIgACXP5Jiehe3OkfOUPjfr+gJOj8LO4Fclwi 3GaNXipE5bE= -----END PUBLIC KEY-----
or as a Base64 string:
MDYwEAYHKoZIzj0CAQYFK4EEAAoDIgACXP5Jiehe3OkfOUPjfr+gJOj8LO4Fclwi3GaNXipE5bE=
-
I also have a CERTIFICATE_SIGNATURE that I need to process.
Problem:
I want to convert the public key and the certificate signature into usable formats in C#. For the public key, I tried the following code, but it doesn’t work as expected:
string PublicKey1 = "MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEXP5Jiehe3OkfOUPjfr+gJOj8LO4Fclwi3GaNXipE5bGdFRjSPLapkhWnzqRYX6KtMRx4nXJzRCU7HrWmtdRkUA==";
byte[] data1 = Convert.FromBase64String(PublicKey1);
string res1 = Encoding.UTF8.GetString(data1);
var tag8 = $"{(char)8}{(char)Encoding.UTF8.GetByteCount(res1)}{res1}";
Request:
- Could you help me correct the code or suggest an alternative approach?
- If possible, provide code for converting public key or certificate signature in any programming language.
Thanks in advance!