mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-01-11 19:44:44 +00:00
fix: more string formatting updates
This commit is contained in:
@@ -70,7 +70,7 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
Debug.Console(0, "DomainName: {0} | HostName: {1} | {1}.{0}@{2}", domainName, hostName, ipAddress);
|
Debug.Console(0, "DomainName: {0} | HostName: {1} | {1}.{0}@{2}", domainName, hostName, ipAddress);
|
||||||
|
|
||||||
var certificate = utility.CreateSelfSignedCertificate($"CN={hostName}.{domainName}", new[] { $"{hostName}.{domainName}", ipAddress }, new[] { KeyPurposeID.IdKPServerAuth, KeyPurposeID.IdKPClientAuth });
|
var certificate = utility.CreateSelfSignedCertificate(string.Format("CN={0}.{1}", hostName, domainName), new[] { string.Format("{0}.{1}", hostName, domainName), ipAddress }, new[] { KeyPurposeID.IdKPServerAuth, KeyPurposeID.IdKPClientAuth });
|
||||||
//Crestron fails to let us do this...perhaps it should be done through their Dll's but haven't tested
|
//Crestron fails to let us do this...perhaps it should be done through their Dll's but haven't tested
|
||||||
//Debug.Print($"CreateCert Storing Certificate To My.LocalMachine");
|
//Debug.Print($"CreateCert Storing Certificate To My.LocalMachine");
|
||||||
//utility.AddCertToStore(certificate, StoreName.My, StoreLocation.LocalMachine);
|
//utility.AddCertToStore(certificate, StoreName.My, StoreLocation.LocalMachine);
|
||||||
@@ -81,7 +81,7 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "WSS CreateCert Failed\r\n{ex.Message}\r\n{ex.StackTrace}");
|
Debug.Console(0, "WSS CreateCert Failed\r\n{0}\r\n{1}", ex.Message, ex.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -316,23 +316,23 @@ namespace PepperDash.Core
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pfx = certificate.Export(X509ContentType.Pfx, CertificatePassword);
|
var pfx = certificate.Export(X509ContentType.Pfx, CertificatePassword);
|
||||||
File.WriteAllBytes($"{Path.Combine(outputDirectory, certName)}.pfx", pfx);
|
File.WriteAllBytes(string.Format("{0}.pfx", Path.Combine(outputDirectory, certName)), pfx);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
CrestronConsole.PrintLine($"Failed to write x509 cert pfx\r\n{ex.Message}");
|
CrestronConsole.PrintLine(string.Format("Failed to write x509 cert pfx\r\n{0}", ex.Message));
|
||||||
}
|
}
|
||||||
// Create Base 64 encoded CER (public key only)
|
// Create Base 64 encoded CER (public key only)
|
||||||
using (var writer = new StreamWriter($"{Path.Combine(outputDirectory, certName)}.cer", false))
|
using (var writer = new StreamWriter($"{Path.Combine(outputDirectory, certName)}.cer", false))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var contents = $"-----BEGIN CERTIFICATE-----\r\n{Convert.ToBase64String(certificate.Export(X509ContentType.Cert), Base64FormattingOptions.InsertLineBreaks)}\r\n-----END CERTIFICATE-----";
|
var contents = string.Format("-----BEGIN CERTIFICATE-----\r\n{0}\r\n-----END CERTIFICATE-----", Convert.ToBase64String(certificate.Export(X509ContentType.Cert), Base64FormattingOptions.InsertLineBreaks));
|
||||||
writer.Write(contents);
|
writer.Write(contents);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
CrestronConsole.PrintLine($"Failed to write x509 cert cer\r\n{ex.Message}");
|
CrestronConsole.PrintLine(string.Format("Failed to write x509 cert cer\r\n{0}", ex.Message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,7 +351,7 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
CrestronConsole.PrintLine($"AddCertToStore Failed\r\n{ex.Message}\r\n{ex.StackTrace}");
|
CrestronConsole.PrintLine(string.Format("AddCertToStore Failed\r\n{0}\r\n{1}", ex.Message, ex.StackTrace));
|
||||||
}
|
}
|
||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
|
|||||||
Reference in New Issue
Block a user