Ben edeceğiz C# konsol uygulaması inşa ediyorum:SSL Sertifikası, başarısız ekleyin Hata: 1312
[1.] kendinden imzalı sertifikayı oluşturun.
[2.] Personal (Yerel Bilgisayar Store) öğesine ekleyin
[3.] Ve nihayet netsh komutuyla makinede bir liman numaranıza bu sertifikayı atayın.
Şimdiye kadar, parça [1.] ve [2.] mükemmel çalışıyor var, ama üzerinde [3.] Ben yararsız ve olmayan gayri hata mesajı ile boğulmuş ediyorum:
SSL Certificate add failed, Error: 1312 A specified logon session does not exist. It may already have been terminated.
Ben bu konuda Microsoft'un resmi sayfaya bakmak gittiğinizde: temelde bu, bir Windows İşletim Sistemi hata olduğunu söyleyip yapmam gerektiği olduğunu oluyor https://support.microsoft.com/en-us/kb/981506
bir düzeltme isteğinde bulunun. Bu Meselesine
Benim Hack Çözüm: Ben başardı
bir yolu bu hatayı atlamak nihayet,> Aç "Sunucu Sertifikaları" Özellik IIS Ev açılması> Ve sonra benim .pfx sertifikasını içe oldu.
.pfx'i IIS'ye içe aktarırken, sorunu sorunsuz bir şekilde çözebiliyor gibiydim. Sadece şu an Openssl için bu iki komutları çalıştırın eğer sipariş
1.) C:\OpenSSL-Win32\bin>openssl req -x509 -sha256 -nodes -days 365 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -newkey rsa:2048 -keyout privateKey.key -out certificate.crt
2.) Yani C:\OpenSSL-Win32\bin>openssl pkcs12 -export -out cert.pfx -inkey privateKey.key -in certificate.crt -passout pass:
bu iki komutları hem çalıştırarak .pfx oluşturmak için gerekli, ve ithalat Onları IIS aracılığıyla Kişisel Yerel Bilgisayar sertifika deposuna, SSL Certificate add failed, Error: 1312
sorunum yok.
Ancak, yeni oluşturulan sertifikayı Kişisel Yerel Bilgisayar sertifika deposuma programlı olarak eklerseniz, Hata: 1312 sorununu alırım.
netsh http add sslcert ipport=0.0.0.0:6613 certhash=8834efd403687b331363ce9e5657ba4ffba0075b appid={e604f84f-e666-4ccf-af52-fdeca666b5e9}
Kafa karıştırıcı Bölüm
:using CERTENROLLLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text;
using System.Security.Cryptography;
using System.Diagnostics;
namespace Generate_X509_Certificate
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Guid.NewGuid().ToString());
Console.ReadLine();
// Launch OpenSSL:
string cPath = @"C:\OpenSSL-Win32\bin\";
string filename = Path.Combine(cPath, @"openssl.exe");
// Generate a .crt file
Console.WriteLine(@"Generating SSL Certificate...");
ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\OpenSSL-Win32\bin\openssl.exe", @"req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt -subj ""/C=US/ST=California/L=SanFrancisco/CN=SecurityEncryption""");
Process.Start(startInfo);
// Combine the .crt with the .key to form a more Windows friendly .pfx
Console.WriteLine(@"Combining Private Key With Certificate...");
Process proc2 = Process.Start(filename, "pkcs12 -export -out cert.pfx -inkey privateKey.key -in certificate.crt -passout pass:");
proc2.Close();
// Store our newly created .pfx file as a variable
X509Certificate2 cert = new X509Certificate2(Directory.GetCurrentDirectory()[email protected]"\cert.pfx");
// Add our .pfx file into the Personal Local Computer store:
var store = new X509Store(StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadWrite);
store.Add(cert);
store.Close();
// Finally, use netsh to assign this newly generated certificate to port 6613
string s1 = "netsh http add sslcert ipport=0.0.0.0:6613 certhash=" + cert.GetCertHashString() + " appid={" + Guid.NewGuid().ToString() + "}";
Process p1 = new Process();
p1.StartInfo.FileName = "netsh.exe";
p1.StartInfo.Arguments = s1;
p1.StartInfo.UseShellExecute = false;
p1.StartInfo.RedirectStandardOutput = true;
// this is where I get the error "SSL Certificate add failed, Error: 1312"
p1.Start();
}
}
}
İşte bu C# programında bunu yürütme değilim olarak mükemmel ince sürece çalışır netsh komutu var: Burada
kod bu.pfx
İçe aktarımını yapmak için .pfx
numaralı iletiyi içe aktarıyorsanız, bu iş parçacığımla openssl
komutlarımı yürütecekseniz openssl tarafından IIS'ye oluşturulan dosya ve son olarak doğru sertifika karması ile görüldüğü gibi netssh
komutunu kullanın. Ancak yukarıdaki C# kodunda otomatik olarak söylediğimi yaptığınızda, Hatası alıyorum.
Başka bir şey,.Bu koddan depoya aktarılmasından daha fazla üretilen pfx, komut satırından el ile netsh
'u denediğinizde çalışmayacaktır.
Herhangi bir fikri olan var mı?
kullanarak mağazada önce sertifika için pfx dahil deneyin. –