none
Unable to set the private key in .net core RRS feed

  • Question

  • Hi

    We have stored our Digi certificates having private key in Hashicorp vault. it contains thee things.Certificate, name and private key.

    I am trying to read the data and return  new x509 certiiate using a .net standard project

      var crypto = new RSACryptoServiceProvider(parms);
                        crypto.FromXmlString(Encoding.UTF8.GetString(Convert.FromBase64String(certificationvalue.Data.PrivateKey)));
                        _
                        x509.PrivateKey = crypto; // getting error that operation is not allowed on this platform.

    How can i fix this

    Thursday, July 9, 2020 9:54 AM

All replies

  • You can't. As documented here, you cannot set this property under .NET Core. A discussion on the rationale and perhaps the workaround is provided in Github.

    Michael Taylor http://www.michaeltaylorp3.net

    Thursday, July 9, 2020 1:54 PM
    Moderator
  • hi

    Try the bellow code .But you have to provide your file path

    string path_ceritificate = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename);
                    if (File.Exists(path_ceritificate))
                    {
                       
                        certBytes = File.ReadAllBytes(path_ceritificate);
                        var totalbyteslength = certBytes.Count();
                     
                    }
                    X509Certificate[] certs = new X509Certificate[]
                  {
               
                new X509Certificate(certBytes)
                  };
    
                   
                    var options = new Cassandra.SSLOptions(protocols, true, null);
    
                  //here I am using cassandra database
    
                    options.SetCertificateCollection(new X509CertificateCollection(certs));
                    // skip validation of remote cert (SSL)
                    options.SetRemoteCertValidationCallback((a1, a2, a3, a4) => true);


    Friday, July 10, 2020 3:30 PM