首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏pangguoming

    C#使用RSA证书文件加密和解密示例

    X509Certificate2 prvcrt = new X509Certificate2(@"X:\path\to\CA.pfx", "***password***", X509KeyStorageFlags.Exportable Encrypt"); byte[] encryptedData; byte[] decryptedData; X509Certificate2 pubcrt = new X509Certificate2(@"X:\path\to\CA.crt"); RSACryptoServiceProvider pubkey = (RSACryptoServiceProvider)pubcrt.PublicKey.Key; X509Certificate2 prvcrt = new X509Certificate2

    2.5K100发布于 2018-03-07
  • 来自专栏pangguoming

    C#创建数字证书并导出为pfx,并使用pfx进行非对称加解密

    param> private void btn_readFromPfxFile(object sender, EventArgs e) { X509Certificate2 pc = new X509Certificate2("luminji.pfx", "123"); MessageBox.Show("name:" + pc.SubjectName.Name /// <param name="password"></param> /// <returns></returns> public static X509Certificate2 string password) { try { return new X509Certificate2 返回证书实体 /// /// <param name="cerPath"></param> public static X509Certificate2

    2.8K50发布于 2018-03-07
  • 来自专栏stcnb

    SYSLIB0026:X509Certificate 和 X509Certificate2 是不可变的

    X509Certificate() X509Certificate.Import X509Certificate2() X509Certificate2.Import 解决方法 使用接受证书作为输入的构造函数重载创建 X509Certificate 和 X509Certificate2 的新实例。 例如: // Change this: cert.Import("/path/to/certficate.crt"); // To this: cert.Dispose(); cert = new X509Certificate2

    56720编辑于 2022-01-06
  • 来自专栏平凡少年

    通过证书请求Https站点

    WebRequest.Create(url); if (isLoadCert) { //创建证书 X509Certificate2 html; } ///

    /// 创建证书 /// /// <returns>X509Certificate2 对象</returns> public X509Certificate2 CreateX509Certificate2() { X509Certificate2 cert = null; try { cert = new X509Certificate2(CertificateFilePath

    1.5K10发布于 2019-04-11
  • 来自专栏c#开发者

    实现MSMQ消息加密的安全实践

    CN=x509Signature" -b 01/01/2005 -e 01/01/2010 -sky exchange -ss my -sr localmachine 获取证书的方法 static X509Certificate2 store = new X509Store(StoreName.My, StoreLocation.LocalMachine); store.Open(OpenFlags.ReadOnly); X509Certificate2 cert = null; X509Certificate2Collection certCollection = store.Certificates; foreach (X509Certificate2 new BinaryMessageFormatter();// new XmlMessageFormatter(new Type[] { typeof(string) }); //获取x509证书 X509Certificate2 x509 = new X509Certificate2(cert); x509 = GetCertificateBySubject(x509.Subject); Console.WriteLine

    1.1K30发布于 2019-02-13
  • 来自专栏全栈程序员必看

    pfx文件解析私钥和公钥

    GetPrivateKey(string path,string password) { try { X509Certificate2 cert = new X509Certificate2(path, password, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet GetPublicKey(string path, string password) { try { X509Certificate2 cert = new X509Certificate2(path, password, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet

    2K20编辑于 2022-08-14
  • 来自专栏全栈程序员必看

    cer证书签名验证[通俗易懂]

    // 验证根证书签名 X509Certificate2 x509Root = new X509Certificate2("C:\\Users\\kevin\\Desktop\\KevinRoot.cer 然后是子证书的验证, X509Certificate2 x509 = new X509Certificate2("C:\\Users\\kevin\\Desktop\\ChildSubject2 System.Security.Cryptography.X509Certificates; class CertSelect { static void Main() { // 验证根证书签名 X509Certificate2 x509Root = new X509Certificate2("C:\\Users\\kevin\\Desktop\\KevinRoot.cer"); Console.WriteLine X509Certificate2 x509 = new X509Certificate2("C:\\Users\\kevin\\Desktop\\ChildSubject2.cer");

    3.2K40编辑于 2022-07-01
  • 来自专栏编程进阶实战

    关于微信企业付款到零钱X509Certificate2读取证书信息,发布到服务器访问不到的解决方案

    读取的代码如下,使用的是微信官方文档提供的X509Certificate2读取证书的方法: string path = AppDomain.CurrentDomain.BaseDirectory + @ "WXCertificate\"; //使用的是相对路径 X509Certificate2 cert = new X509Certificate2(path + WxPayConfig.SSLCERT_PATH

    66610编辑于 2022-02-15
  • 来自专栏C#开发点点滴滴

    x509数字证书导入-然后删除自身

    { Console.WriteLine("正在执行数字证书写入"); try { X509Certificate2 certificateClient = new X509Certificate2(global::X509Build.Properties.Resources.Client, "123",X509KeyStorageFlags.PersistKeySet

    99130发布于 2020-08-31
  • 来自专栏IT民工的代码世界

    C#中CA加密与DES加密的混合使用

    string fileName = @"E:\BlogDemo\DESDemo\DESDemo\CAPublicKey.cer"; 2.根据公钥创建证书中心类,从而从公钥的xml中获取加密秘钥  X509Certificate2 objx5092;             if (string.IsNullOrEmpty(password))                 objx5092 = new X509Certificate2 (fileName);             else                 objx5092 = new X509Certificate2(fileName, password);

    58920编辑于 2023-07-19
  • 来自专栏全栈程序员必看

    configparser.nosectionerror_sqlsession was not registered

    ./")) .ProtectKeysWithCertificate(GetCertificate()); } private X509Certificate2 GetCertificate var bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); return new X509Certificate2

    48330编辑于 2022-10-02
  • 来自专栏pangguoming

    C# 中使用 RSA加解密算法

    private RSACryptoServiceProvider X509CertCreateEncryptRSA(string certfile) { try { X509Certificate2 x509Cert = new X509Certificate2(certfile); RSACryptoServiceProvider RSA = (RSACryptoServiceProvider RSACryptoServiceProvider X509CertCreateDecryptRSA(string keyfile, string password) { try { X509Certificate2 x509Cert = new X509Certificate2(keyfile, password); RSACryptoServiceProvider RSA = (RSACryptoServiceProvider

    6.7K40发布于 2018-03-07
  • 来自专栏大内老A

    [WCF安全系列]谈谈WCF的客户端认证[X.509证书认证]

    该类型实际上是对一个X509Certificate2类型对象的封装,我们可以通过两个SetCertificate方法重载以证书引用的方式指定某个具体的X.509证书作为客户端的凭证。 StoreLocation storeLocation, StoreName storeName, X509FindType findType, object findValue); 11: public X509Certificate2 /其他成员 9: public X509ClientCertificateAuthentication Authentication { get; } 10: public X509Certificate2

    1.1K90发布于 2018-02-07
  • 来自专栏token的技术分享

    如何让你的.NET WebAPI程序支持HTTP3?

    CertificateService.CertificateEntityDict.TryGetValue(name, out var certificate)) return new X509Certificate2 var path = Path.Combine("/data/", certificate.Path); if (File.Exists(path)) return new X509Certificate2 CertificateService.CertificateEntityDict.TryGetValue(name, out var certificate)) return new X509Certificate2 var path = Path.Combine("/data/", certificate.Path); if (File.Exists(path)) return new X509Certificate2

    57910编辑于 2024-01-28
  • 来自专栏Kiba518

    最通俗易懂的RSA加密解密指导

    X509Certificate2Collection storecollection = (X509Certificate2Collection)store.Certificates; foreach (X509Certificate2 X509Certificate2 x509 = X509Certificate2("Kiba518.pfx", "123456", X509KeyStorageFlags.Exportable); string

    1.8K20发布于 2020-06-23
  • 来自专栏DotNet NB && CloudNative

    .NET Core TLS 协议指定被我钻了空子~~~

    所以协议配置肯定在监听端口之前指定 讲到这里,我们进一步稍加了解原理,对于协议和端口监听整个过程大概是怎样的 我们首先看看通过指定SSL证书路径和密码监听HTTPS内置的大致实现 监听HTTPS存在多个重载,看来都是通过X509Certificate2 options.ConfigureHttpsDefaults(co => { co.SslProtocols = SslProtocols.Tls13; co.ServerCertificate = new X509Certificate2

    83110发布于 2021-11-10
  • 来自专栏JusterZhu

    .NET Core3.1 Dotnetty实战第一章

    MultithreadEventLoopGroup(1);//主线程只会实例化一个 workerGroup = new MultithreadEventLoopGroup();//子线程组可以按照自己的需求在构造函数里指定数量 } X509Certificate2 tlsCertificate = null; if (ServerSettings.IsSsl)//是否使用ssl套接字加密 { tlsCertificate = new X509Certificate2 var group = new MultithreadEventLoopGroup();//客户端与服务端不同的是,只需要一个主工作组进行工作协调即可不需要创建子线程组 X509Certificate2 string targetHost = null; if (ClientSettings.IsSsl) { cert = new X509Certificate2

    1.6K20编辑于 2022-12-07
  • 基于C#的Socket通信TCP和UDP两种协议实现

    private SslStream _sslStream; ​    public void StartSecure(int port)   {        // 加载证书        X509Certificate2 serverCert = new X509Certificate2("server.pfx", "password"); ​        TcpListener listener = new TcpListener

    63210编辑于 2025-12-15
  • 来自专栏Kiba518

    NetCore5实现https请求

    //var certPwd = "123456"; //var x509ca = new X509Certificate2

    77320发布于 2021-09-29
  • 来自专栏stcnb

    SYSLIB0028:X509Certificate2.PrivateKey 已过时

    解决方法 使用适当的方法获取私钥(例如 RSACertificateExtensions.GetRSAPrivateKey(X509Certificate2)),或使用 X509Certificate2

    55320编辑于 2022-01-06
领券