Search code examples
c#.netsslx509certificatemage

Get X509 Certificate from mage signed manifest file


I have an OutlookAddin.vsto file (yes, its an Outlook addin VSTO file) which contains a signed certificate, signed using mage.exe. It successfully created a <X509Certificate> tags which contain the encoded public certificate as far as I can tell embedded within it, of this format:

MIIFBDCCA+ygAwIBAgIQeCmDjQ...3OsgfHUZkAl/GR77wxDooVNr2Hk+aohlDpG9J+PxeQiAohItHIG4=

How can I read this certificate back as an X509 certificate in C#? I can't seem to find a suitable X509Certificate2 constructor to make this magic happen in my C#, .NET application.


Solution

  • This string probably represents the certificate raw data encoded as base64. Use the Convert.FromBase64String method to convert this into a byte[] and then use the X509Certificate2 constructor that takes a byte[] to create the certificate object.