huysentruitw / pem-utils

Managed .NET (C#) utility library for working with PEM files with DER/ASN.1 encoding

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Method not found exception

opened this issue · comments

Does not seem to work for me as I'm seeing the following exception:

Method not found: 'System.Collections.Generic.IReadOnlyList`1<DerConverter.Asn.DerAsnType> DerConverter.Asn.DerAsnSequence.get_Items()'.
at PemUtils.PemReader.ReadPublicKey(DerAsnType der)
at PemUtils.PemReader.ReadRsaKey()

Using the following code:

static void Main()
{
    var pub =
        "-----BEGIN PUBLIC KEY-----\n" +
        "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKuMYcirPj81WBtMituJJenF0CG/HYLc\n" +
        "AUOtWKl1HchC0dM8VRRBI/HV+nZcweXzpjhX8ySa9s7kJneP0cuJiU8CAwEAAQ==\n" +
        "-----END PUBLIC KEY-----";
        
    using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(pub)))
    using (var reader = new PemReader(stream))
    {
        var rsaParameters = reader.ReadRsaKey();
    }
}

I am using version 1.0.0.21

What's the target framework of the project you're trying to use this in?

Can you also update the DerConverter package to 1.0.0.21 under Solution > Manage nuget packages and see how that goes?

Thanks! Updating the DerConverter to 1.0.0.21 fixed the issue.

For some reason, when installing PemUtils it drags in an old version of the dependent DerConverter package, not sure how to enforce this, will have to do some research 🙂