x509certificate2

In C#, sign an xml with a x.509 certificate and check the signature

拟墨画扇 提交于 2019-11-27 18:02:36
I'm trying to sign an XML file using a x.509 certificate, I can use the private key to sign the document and then use the CheckSignature method (it has an overload that receives a certificate as parameter) to verify the signature. The problem is that the user who validates the signature must have the certificate, my concern is, if the user has the certificate then he has access to the private key, and as I understand, this is private and should be available only to the user who signs. What am I missing? Thanks for your help. In .NET, If you get your X509 cert from a .pfx file, like this:

X509Certificate2 makes IIS crash

坚强是说给别人听的谎言 提交于 2019-11-27 17:14:07
问题 When newing up an instance of X509Certificate2(string, string) my IIS process simply crashes. No .Net exception, no nothing, except of this in my event log Faulting application name: w3wp.exe, version: 8.0.9200.16384, time stamp: 0x50108835 Faulting module name: ntdll.dll, version: 6.2.9200.16420, time stamp: 0x505ab405 Exception code: 0xc0000374 Fault offset: 0x00000000000ea485 Faulting process id: 0x102c Faulting application start time: 0x01ce10301e250c4d Faulting application path: c:

how to create a completely new x509Certificate2 in .net?

爷,独闯天下 提交于 2019-11-27 12:55:59
问题 I google it from web, find many samples to generate a new x509Certificate2 from a file in .net, but there is no one sample to show how to generate a completely new x509Certificate2 from the beginning in .net. Is there any one that can tell me how to do it in .net? Thank you very much. 回答1: Here's a code you can use: static X509Certificate2 GenerateCertificate(string certName) { var keypairgen = new RsaKeyPairGenerator(); keypairgen.Init(new KeyGenerationParameters(new SecureRandom(new

X509 certificate not loading private key file on server

我只是一个虾纸丫 提交于 2019-11-27 10:07:44
问题 I'm using the Google Analytics API and I followed this SO question to set up the OAuth: https://stackoverflow.com/a/13013265/1299363 Here is my OAuth code: public void SetupOAuth () { var Cert = new X509Certificate2( PrivateKeyPath, "notasecret", X509KeyStorageFlags.Exportable); var Provider = new AssertionFlowClient(GoogleAuthenticationServer.Description, Cert) { ServiceAccountId = ServiceAccountUser, Scope = ApiUrl + "analytics.readonly" }; var Auth = new OAuth2Authenticator

How to serialize and deserialize a PFX certificate in Azure Key Vault?

落花浮王杯 提交于 2019-11-27 08:55:14
I have a bunch of strings and pfx certificates, which I want to store in Azure Key vault, where only allowed users/apps will be able to get them. It is not hard to do store a string as a Secret, but how can I serialize a certificate in such way that I could retrieve it and deserialize as an X509Certificate2 object in C#? I tried to store it as a key. Here is the Azure powershell code $securepfxpwd = ConvertTo-SecureString -String 'superSecurePassword' -AsPlainText -Force $key = Add-AzureKeyVaultKey -VaultName 'UltraVault' -Name 'MyCertificate' -KeyFilePath 'D:\Certificates\BlaBla.pfx'

What is the rationale for all the different X509KeyStorageFlags?

你说的曾经没有我的故事 提交于 2019-11-27 03:28:27
问题 Today, a colleague hit yet another bug related to these! I've found these flags really frustrating in past myself, because if you get them slightly wrong while instantiating X509Certificate2 objects, or exporting them, or saving them in an X509Store you can land in situations with all sorts of weird bugs such as: unexpectedly can't tell NETSH.exe or ASP.net to use a certain SSL certificate [by its thumbprint], even though you have that cert in your machine store unexpectedly you can export

Exporting a Certificate as BASE-64 encoded .cer

南笙酒味 提交于 2019-11-27 02:03:12
问题 I am trying to export a cert without the private key as as BASE-64 encoded file, same as exporting it from windows. When exported from windows I am able to open the .cer file in notepad. When I try the following and open on notepad I get binary data...I think it is...not readable. X509Certificate2 cert = new X509Certificate2("c:\\myCert.pfx", "test", X509KeyStorageFlags.Exportable); File.WriteAllBytes("c:\\testcer.cer", cert.Export(X509ContentType.Cert)); I tried removing the

How to programmatically import a pfx with a chain of certificates into the certificate store?

拟墨画扇 提交于 2019-11-26 22:50:43
问题 I am trying to programmatically import a X509 certificate (pfx / PKCS#12) in my local machine's certificate store. This particular certificate has a chain of certificates, the certification path looks something like this: Root certificate CA Organization certificate CA Organization 2 certificate CA My certificate The code I use looks like this: cert = new X509Certificate2(pathToCert, password); if (cert != null) { var store = new X509Store(StoreName.My, StoreLocation.LocalMachine); store.Open

The request was aborted: Could not create SSL/TLS secure channel [duplicate]

雨燕双飞 提交于 2019-11-26 22:24:02
问题 Possible Duplicate: The request was aborted: Could not create SSL/TLS secure channel I am trying to send a http request with a client side certificate. The file, in this case a .p12 file. However when it reaches the line responseStream = httpRequest.GetRequestStream(); it throws a WebException: System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel. I am debugging this on IIS7.5 (on windows 7), where the app pool identity is "LocalSystem". How do i solve

In C#, sign an xml with a x.509 certificate and check the signature

旧巷老猫 提交于 2019-11-26 19:19:36
问题 I'm trying to sign an XML file using a x.509 certificate, I can use the private key to sign the document and then use the CheckSignature method (it has an overload that receives a certificate as parameter) to verify the signature. The problem is that the user who validates the signature must have the certificate, my concern is, if the user has the certificate then he has access to the private key, and as I understand, this is private and should be available only to the user who signs. What am