errors on setup

vhuzov
Regular Visitor

Re: How to run C# Sample Code for MLE

Hi @asaldanha

 

I know it is too late but want to leave the solution for the next error   

 

Unable to cast object of type 'Org.BouncyCastle.X509.X509Certificate' to type 'Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair'.

The code below resolve this error

 

   private static RSA ImportPrivateKey(string privateKeyFile)

{

        var pr = new PemReader(File.OpenText(privateKeyFile));

        var rsaPrivateKeyParameters = (RsaPrivateCrtKeyParameters)pr.ReadObject();
        var rsaParams = DotNetUtilities.ToRSAParameters(rsaPrivateKeyParameters);

        var rsa = RSA.Create();
        rsa.ImportParameters(rsaParams);

        return rsa;

}
QRTIT
Helper

errors on setup

in the first jwt.encode, i'm getting this "RsaKeyManagement algorithm expects key to be of CngKey or RSACryptoServiceProvider types."

 

Also, no matter what i do the jose-jwt corrupts my nuget setup.  The other packages are fine.  The error is: "Part URI is not valid per rules defined in the Open Packaging Conventions specification."

So, it seems that jose was imported but, that's failing.

I'd be more comfortable if it didn't corrupt nuget.

 

I'm on Windows 11 Enterprise, vs2015, with .net 4.6.