How to store a public key in a machine-level RSA key container

后端 未结 2 623
时光取名叫无心
时光取名叫无心 2020-12-16 02:46

I\'m having a problem using a machine level RSA key container when storing only the public key of a public/private key pair.

The following code creates a public/pri

相关标签:
2条回答
  • 2020-12-16 02:55

    It seems that key containers are not intended for this purpose (this is implied by "How to: Store Asymmetric Keys in a Key Container" from the .NET Framework Developer's Guide, and confirmed by a disccusion on MSDN).

    Other mechanisms, such as storing the key in an XML file, need to be used to achieve this goal.

    0 讨论(0)
  • 2020-12-16 03:00

    This link may help you. http://msdn.microsoft.com/en-IN/library/tswxhw92(v=vs.80).aspx

    var cp = new CspParameters();
    cp.KeyContainerName = ContainerName;
    
    // Create a new instance of RSACryptoServiceProvider that accesses
    // the key container.
    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp);
    
    // Delete the key entry in the container.
    rsa.PersistKeyInCsp = false;
    
    // Call Clear to release resources and delete the key from the container.
    rsa.Clear();
    

    This is what it says about key deletion.

    0 讨论(0)
提交回复
热议问题