English 中文(简体)
如何在.NET 核心中使用 OpenSSL 。 NET 核心
原标题:How to use OpenSSL in.NET Core
我在NuGet的. net核心项目中添加一个 OpenSSL 软件包( System. Security. Cryptography. OpenSsl.
问题回答
(You need to be on .net framework 4.7.2 or more) I was searching for the same thing, and I found : // Here we define content which will be in certificate like name or state X500DistinguishedName distinguishedName = new X500DistinguishedName("C=" + countryCode + ",ST=" + state + ",L=" + locality + ",O=" + organization + ",CN=" + fullName); using (RSA rsa = RSA.Create()) { // create RSA key CertificateRequest request = new CertificateRequest(distinguishedName, rsa, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1); request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.DataEncipherment | X509KeyUsageFlags.KeyEncipherment | X509KeyUsageFlags.DigitalSignature, false)); request.CertificateExtensions.Add(new X509EnhancedKeyUsageExtension(new OidCollection { new Oid("1.3.6.1.5.5.7.3.1") }, false)); X509Certificate2 certificate = request.CreateSelfSigned(new DateTimeOffset(DateTime.UtcNow.AddDays(-1)), new DateTimeOffset(DateTime.UtcNow.AddDays(3650))); // Now let s get files: byte[] cert = certificate.Export(X509ContentType.Cert, password); //.crt byte[] p12 = certificate.Export(X509ContentType.Pkcs12, password); //.p12 } Source: https://stackoverflow.com/a/50138133/10952503




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签