From 7872468af2517ffd43ffc617298e07ad4d95fced Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 15 Nov 2023 17:14:13 -0700 Subject: [PATCH] fix: more string formatting updates --- src/Pepperdash Core/Logging/DebugWebsocketSink.cs | 4 ++-- src/Pepperdash Core/Web/BouncyCertificate.cs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Pepperdash Core/Logging/DebugWebsocketSink.cs b/src/Pepperdash Core/Logging/DebugWebsocketSink.cs index 4c6c356..fad13e2 100644 --- a/src/Pepperdash Core/Logging/DebugWebsocketSink.cs +++ b/src/Pepperdash Core/Logging/DebugWebsocketSink.cs @@ -70,7 +70,7 @@ namespace PepperDash.Core 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 //Debug.Print($"CreateCert Storing Certificate To My.LocalMachine"); //utility.AddCertToStore(certificate, StoreName.My, StoreLocation.LocalMachine); @@ -81,7 +81,7 @@ namespace PepperDash.Core } 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); } } diff --git a/src/Pepperdash Core/Web/BouncyCertificate.cs b/src/Pepperdash Core/Web/BouncyCertificate.cs index c969235..67c129f 100644 --- a/src/Pepperdash Core/Web/BouncyCertificate.cs +++ b/src/Pepperdash Core/Web/BouncyCertificate.cs @@ -316,23 +316,23 @@ namespace PepperDash.Core try { 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) { - 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) using (var writer = new StreamWriter($"{Path.Combine(outputDirectory, certName)}.cer", false)) { 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); } 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) { - 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;