Install certificates in to the Windows Local user certificate store in C#
Tag : chash , By : user98986
Date : March 29 2020, 07:55 AM
it should still fix some issue Turns out you first need to impersonate the user. Using the very nice library described in A small C# Class for impersonating a User, you can do the following: using (new Impersonator("username", "", "password"))
{
try
{
X509Store serviceRuntimeUserCertificateStore = new X509Store(StoreName.My);
string baseDir = AppDomain.CurrentDomain.BaseDirectory;
string certPath = Path.Combine(baseDir, certificateFolder);
string certificateFile = "c:\\file.cert";
string certificatePassword = "somePassword";
string certificateLocation = certPath + "\\" + certificateFile;
InstallCertificate(certificateLocation, certificatePassword);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
private static void InstallCertificate(string certificatePath, string certificatePassword)
{
try
{
var serviceRuntimeUserCertificateStore = new X509Store(StoreName.My);
serviceRuntimeUserCertificateStore.Open(OpenFlags.ReadWrite);
X509Certificate2 cert;
try
{
cert = new X509Certificate2(certificatePath, certificatePassword);
}
catch(Exception ex)
{
Console.WriteLine("Failed to load certificate " + certificatePath);
throw new DataException("Certificate appeared to load successfully but also seems to be null.", ex);
}
serviceRuntimeUserCertificateStore.Add(cert);
serviceRuntimeUserCertificateStore.Close();
}
catch(Exception)
{
Console.WriteLine("Failed to install {0}. Check the certificate index entry and verify the certificate file exists.", certificatePath);
}
}
|
How can I create a Windows Service which updates itself without user interaction
Tag : chash , By : n1ckless_id
Date : March 29 2020, 07:55 AM
I wish this help you Here is the solution I ended up with: When installing the service, I gave the service user permission to start and stop the service. See my question on service permissions for more details.
|
Install python for windows with no user interaction
Tag : python , By : Mare Astra
Date : March 29 2020, 07:55 AM
around this issue Unpack the contents of Winpython, copy this folder to any windows-machine you like. Your done :-). Concerning your 2nd question: Winpython is fully portable and comes with a GUI-Installer for 3rd-party python packages. Install all you need ONLY ONCE and copy the Winpython folder afterwards to all Windows-PC.
|
Any way to use self signed certificates on the windows phone 7 emulator?
Date : March 29 2020, 07:55 AM
|
How to install self-signed certificates in iOS 11
Date : March 29 2020, 07:55 AM
it helps some times If you are not seeing the certificate under General->About->Certificate Trust Settings, then you probably do not have the ROOT CA installed. Very important -- needs to be a ROOT CA, not an intermediary CA. This is very easy to determine by using openssl: $ openssl s_client -showcerts -connect myserver.com:443 </dev/null
Certificate chain
0 s:/C=US/ST=California/L=SAN FRANCISCO/O=mycompany.com, inc./OU=InfraSec/CN=myserver.com
i:/C=US/O=mycompany.com, inc./CN=mycompany.com Internal CA 1A
-----BEGIN CERTIFICATE-----
....encoded cert in PEM format....
-----END CERTIFICATE-----
$ openssl x509 -in myfile.pem -out myfile.der -outform DER
|