Tag: x509certificate

撤销function无法检查证书的撤销

我试图在C#中使用X509Chainvalidation证书尚未被撤销。 X509Chain chain = new X509Chain(); chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EndCertificateOnly; chain.Build(certificate); 这将返回以下状态: 撤销function无法检查证书的撤销 我想检查已撤销的证书,而不仅仅是关闭错误。 如何解决此问题或至少更好地了解原因(例如,如何找出检查CRL的位置?)

我的自定义SSLvalidation逻辑如何安全地处理例外的RemoteCertificateNameMismatch?

我尝试将文件上传到我的域https://vault.veodin.com/ ,该文件位于webfaction.com 当您打开此URL时,浏览器会警告您名称不匹配,因为SSL证书是针对webfaction.com而不是针对veodin.com发布的 因此,当我尝试使用.Net WebClient将文件上载到此域时,会出现sslPolicyError System.Net.Security.SslPolicyErrors.RemoteCertificateNameMismatch。 出于我的目的,足以确保上传目标托管在* .webfaction.com上。 信任certificate.subject是否安全? 背景: 更新:我使用自定义CertificateValidationCallback来validation证书主题和证书颁发者是否符合我的预期。 ServicePointManager.ServerCertificateValidationCallback = MyCertificatePolicy.CertificateValidationCallBack; … public class MyCertificatePolicy { public static bool CertificateValidationCallBack( object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { // If the certificate is a valid, signed certificate, return true. if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None) { return true; } //if there is a […]

在ASP.Net应用程序中安全地存储(加密)数据

我有一个asp.net应用程序,可以通过互联网使用Web浏览器访问。 它在Web服务器上运行,并与后端数据库进行通信。 一些用户希望使用该应用程序来存储一些私人数据。 这个要求是: 1)只有存储数据的用户才能看到它。 2)开发人员/ dbas不应该能够看到数据。 3)如果Web服务器和数据库服务器受到攻击,则黑客必须无法解密数据。 所以,很明显我将不得不加密这些数据。 如果我加密它会在某个地方有一个密钥,可能是盐/ IV。 问题是我在哪里存储用于执行解密的数据? 如果我将它存储在数据库或Web服务器中,那么开发人员,dba或黑客可以访问它并解密数据。 我认为我理想的解决方案是将私钥放在客户机上,这样他们就完全负责了。 但我不知道如何使用asp.net Web应用程序来解决这个问题。 我相信我可以创建一个也存储私钥(PFX)的证书。 客户公司可以使用组策略将证书部署到其域。 但是,ASP.Net应用程序可以请求Web浏览器向其发送私钥,以便它可以执行解密吗? 解密客户端将是最好的,但除了在JavaScript中创建一些东西,我不知道这是如何可能的。 欢迎任何建议。

当您知道无效证书是安全的时,测试X509Certificate.Thumbprint属性是否安全?

我正在尝试使用SmtpClient.Send以编程方式发送电子邮件。 我正在尝试发送电子邮件时收到AuthenticationException 。 这是因为证书validation程序失败。 我知道证书是正确的,但我也明白,信任所有证书并不安全,就像这样做的建议: ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; }; 所以我想知道测试Thumbprint是否足够安全已知的有效证书指纹,如下所示: ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { if (sslPolicyErrors == SslPolicyErrors.None) return true; else if (certificate.GetCertHashString().Equals(“B1248012B10248012B”)) return true; return false; };

以编程方式将x509证书上载到azure应用程序清单

有没有办法以编程方式将Visual Studio中创建的x509证书上载到Azure应用程序清单中? 我按照这篇文章创建了x509证书: public static X509Certificate2 GenerateSelfSignedCertificate(string subjectName, string issuerName, AsymmetricKeyParameter issuerPrivKey) { const int keyStrength = 2048; //generate random numbers CryptoApiRandomGenerator randomGenerator = new CryptoApiRandomGenerator(); SecureRandom random = new SecureRandom(randomGenerator); ISignatureFactory signatureFactory = new Asn1SignatureFactory(“SHA512WITHRSA”, issuerPrivKey, random); //the certificate generator X509V3CertificateGenerator certificateGenerator = new X509V3CertificateGenerator(); certificateGenerator.AddExtension(X509Extensions.ExtendedKeyUsage.Id, true, new ExtendedKeyUsage(KeyPurposeID.IdKPServerAuth)); //serial number BigInteger serialNumber = […]

HttpListener服务器返回错误:(503)服务不可用

我正在尝试创建一个使用x509证书进行客户端/服务器身份validation的http侦听器。 我的服务器代码如下。 _listener = new HttpListener(); _listener.Prefixes.Add(“https://localhost:8006/”); _listener.Start(); HttpListenerContext context = _listener.GetContext(); 我的客户端代码如下 string url = “https://localhost:8006/”; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); var store = new X509Store(StoreName.TrustedPeople, StoreLocation.LocalMachine); store.Open(OpenFlags.ReadOnly); var cert = store.Certificates.Find(X509FindType.FindBySubjectName, “localhost”, true); request.ClientCertificates.Add((X509Certificate)cert[0]); ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, policyErrs) => { return policyErrs == System.Net.Security.SslPolicyErrors.None; }; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 我相信我已经正确配置了一切。 没有证书策略错误,我已将ssl证书绑定到端口,并且不需要提升权限来运行侦听器。 如果我在代码中或通过Chrome发出网络请求,我会收到此错误消息。 […]

使用C#/ Powershell设置Active Directory“安全身份映射”/“名称映射”不会添加到正确的“存储”

我已按照本指南操作: https : //blogs.msdn.microsoft.com/adpowershell/2009/04/26/working-with-certificates-in-active-directory-powershell/ 证书已成功添加到用户的已发布证书中。 但这不是我真正想要的。 相反,我希望将证书添加到AD用户的X509证书(Active Directory中的名称映射/安全身份映射) 安全身份映射 有没有办法在C#或Powershell中执行此操作?

使用自签名证书

我有这个代码: X509Chain x509Chain = new X509Chain(); x509Chain.ChainPolicy.ExtraStore.Add(certificate1); x509Chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; x509Chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot; x509Chain.Build(certificate2); foreach (X509ChainElement x509ChainElement in x509Chain.ChainElements) { Log(“Name: ” + x509ChainElement.Certificate.GetNameInfo(X509NameType.SimpleName, false)); foreach (X509ChainStatus x509ChainStatus in x509ChainElement.ChainElementStatus) Log(“status: ” + x509ChainStatus.StatusInformation); if (x509ChainElement.ChainElementStatus.Length != 0 && (x509ChainElement.Certificate.Thumbprint != certificate1.Thumbprint))// || x509ChainElement.ChainElementStatus[0].Status != X509ChainStatusFlags.UntrustedRoot)) return false; } 如果证书是自签名的(或者至少我认为它没有安装),我无法设法安装证书。 在状态日志消息我得到这个: 已处理证书链,但在信任提供程序不信任的根证书中终止 我怎么能忽略那张支票呢?

如何使用.NET P / Invoke CryptUIWizExport函数

任何人都可以将这两个cryptui.dll函数/结构翻译成C#.NET [dllimport]包装器吗? 我想P / Invoke CryptUIWizExport函数来显示Windows证书导出向导。 特别是,我需要将.NET X509Certificate作为参数传递给CryptUIWizExport函数。 非常感谢你的帮助! CryptUIWizExport函数 BOOL WINAPI CryptUIWizExport( __in DWORD dwFlags, __in HWND hwndParent, __in LPCWSTR pwszWizardTitle, __in PCCRYPTUI_WIZ_EXPORT_INFO pExportInfo, __in void *pvoid ); typedef struct _CRYPTUI_WIZ_EXPORT_INFO { DWORD dwSize; LPCWSTR pwszExportFileName; DWORD dwSubjectChoice; union { PCCERT_CONTEXT pCertContext; PCCTL_CONTEXT pCTLContext; PCCRL_CONTEXT pCRLContext; HCERTSTORE hCertStore; } ; DWORD cStores; HCERTSTORE *rghStores; […]

从远程主机自动下载X509证书链

我正在构建一些.net代码,它将在我们的一台服务器上按计划无人值守运行。 其执行的一部分要求它执行Java可执行文件,该可执行文件通过SSL与某些Web资源和服务进行通信。 如果它通过SSL做某事并且它没有远程证书链中的每一个证书,那么Java绝对会适合。 所以在.net中,我需要能够具体的https:// [无论] .com资源,并需要它在本地下载整个远程链。 为什么我要自动执行此操作? 因为我希望简化部署并且不必执行此操作4次,然后每次Oracle证书之一到期时再次执行此操作。 我这样做: X509Certificate2 lowestCert = SecurityHelper.DownloadSslCertificate(keyDownloadLocation); X509Chain chain = new X509Chain(); chain.Build(lowestCert); int counter = 0; foreach (X509ChainElement el in chain.ChainElements) { //Extract certificate X509Certificate2 chainCert = el.Certificate; //Come up with an alias and save location string alias = certBaseName + counter; string localLocation = Path.GetDirectoryName( System.Reflection.Assembly.GetEntryAssembly().Location ) […]