x509certificate2

Verify Private Key Protection before signing with RSACryptoServiceProvider

六月ゝ 毕业季﹏ 提交于 2019-12-24 15:10:03
问题 When signing data with RSACryptoServiceProvider in C#, I have a requirement to ensure the certificate was imported with strong key protection and a high security level to require the user enters the password every time they sign with the key. Here's a quick simplified sample of the signing code: X509Store myCurrentUserStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); myCurrentUserStore.Open(OpenFlags.MaxAllowed); X509Certificate2 currentCertificate = myCurrentUserStore

X509Certificate2 from store with private key

扶醉桌前 提交于 2019-12-24 14:51:19
问题 I have a X509Certificate2 with private key NOT exportable from the Windows store with this code: X509Certificate2 oCertificato = null; X509Store my = new X509Store(StoreName.My, StoreLocation.CurrentUser); my.Open(OpenFlags.ReadOnly); System.Security.Cryptography.RSACryptoServiceProvider csp = null; foreach (X509Certificate2 cert in my.Certificates) { if (cert.SerialNumber.Trim() == cSerial) { csp = (System.Security.Cryptography.RSACryptoServiceProvider)cert.PrivateKey; oCertificato = cert;

IdentityServer3 - X509Certificate2 Constructor Error (“Cannot find requested object”)

依然范特西╮ 提交于 2019-12-24 08:27:27
问题 I am trying to get IdentityServer3 setup and am following along and using a Pluralsight video (https://app.pluralsight.com/library/courses/building-securing-restful-api-aspdotnet/table-of-contents) as reference. I'm at the point of basic IS3 setup and am stuck at the "SigningCertificate" assignment for the ".UseIdentityServer()" call. I've seen similar code elsewhere on the Internet. My relevant code: public X509Certificate2 LoadCertificate() { var baseFolder = AppDomain.CurrentDomain

NotImplementedException when Accessing ServiceAccountCredential C#

北慕城南 提交于 2019-12-24 08:23:14
问题 I have a Windows app that access a Google spreadsheet to create a phone book. When I try to open the phone book, I get flagged with System.NotImplementedException: The method or operation is not implemented. I'm not really sure why, because it seems like it is being implemented? This is the first spot that's being flagged with the issue: internal object FromCertificate(X509Certificate2 certificate) { throw new NotImplementedException(); //Error flags this line } This is the second. As far as

Load a Certificate Using X509Certificate2 with ECC Public Key

一曲冷凌霜 提交于 2019-12-24 04:56:50
问题 This is a newbie question. I'm trying to load a .der certificate using: X509Certificate2 cert = new X509Certificate2(@"c:\temp\mycert.der"); RSACryptoServiceProvider csp = (RSACryptoServiceProvider)cert.PublicKey.Key But I get a "The certificate key algorithm is not supported" error on the 2nd line. When I import this certificate to MMC I can see the public key like . Is it valid? How do I get it in code? 回答1: Prior to .NET 4.6.1 ECDSA keys were not supported. For legacy/compatibility reasons

Load a Certificate Using X509Certificate2 with ECC Public Key

梦想与她 提交于 2019-12-24 04:56:04
问题 This is a newbie question. I'm trying to load a .der certificate using: X509Certificate2 cert = new X509Certificate2(@"c:\temp\mycert.der"); RSACryptoServiceProvider csp = (RSACryptoServiceProvider)cert.PublicKey.Key But I get a "The certificate key algorithm is not supported" error on the 2nd line. When I import this certificate to MMC I can see the public key like . Is it valid? How do I get it in code? 回答1: Prior to .NET 4.6.1 ECDSA keys were not supported. For legacy/compatibility reasons

Azure Web Application new X509Certificate2() causing System.Security.Cryptography.CryptographicException: Access denied

ⅰ亾dé卋堺 提交于 2019-12-23 20:03:22
问题 Right now I am uploading a .pfx file, taking in a password and calling var cert = new X509Certificate2(fileData, password); And storing things like the thumbprint, etc. I do not need to actually store this on the server, just validate that it is a valid cert and store some information. On local this works (obviously I have better access to my key store) but when I put it up in azure I get the error: System.Security.Cryptography.CryptographicException: Access denied. Is there any way to get

Empty PrivateKey in x509certificate2

流过昼夜 提交于 2019-12-23 19:51:28
问题 I have installed certificate on local machine store (win7) with private key. In c# code I do that: X509Certificate2 cert = null; var store = new X509Store(storeName, storeLocation); store.Open(OpenFlags.ReadOnly); try { var result = store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false); ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; ServicePointManager.ServerCertificateValidationCallback = delegate { return

What is the implication of not using X509Store.Close method?

旧时模样 提交于 2019-12-23 18:31:12
问题 If I keep initializing X509Store certificate stores and don't use their Close() method, what is the implication of this? In the code example given in documentation, they don't use try..finally block to make a call to Close method. If this certificate store is something that needs to be freed, why does not the API of the class designed to derive from IDisposable or why does not this class have a implicit destructor called when object goes out of scope? 回答1: In .NET 4.6, X509Store was modified

Can I use an X509Certificate2 within ASP.NET without using a certificate store?

帅比萌擦擦* 提交于 2019-12-23 08:54:21
问题 I am trying to use an X509Certificate within an ASP.NET web service within the Rackspace Cloud. I have a feeling the certificate stores on the cloud nodes maybe causing problems. I also have a question related to this with the exception that I am receiving at SslStream.AuthenticateAsClient Exception when using iPhone Apple Push Notification Provider (apns-sharp) C# Within the apns-sharp project I was using the following code: certificate = new X509Certificate2(p12File) However I received an