From d6a63fccacec3f6ac283bfb4f1f6d39daa29f858 Mon Sep 17 00:00:00 2001 From: Chris Lockwood Date: Sat, 11 Mar 2023 12:44:00 +0000 Subject: [PATCH] Better handle missing system proxy/credentials --- src/WebSocketClient.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/WebSocketClient.cs b/src/WebSocketClient.cs index e83e47e..6c0eb0d 100644 --- a/src/WebSocketClient.cs +++ b/src/WebSocketClient.cs @@ -289,12 +289,11 @@ namespace MeshCentralRouter // Send proxy connection request wsrawstream = wsclient.GetStream(); - string userCreds = proxyUri.UserInfo; string basicAuth = ""; - if (userCreds.Length > 0) + if (proxyUri?.UserInfo != null) { // Base64 encode for basic authentication - userCreds = System.Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(userCreds)); + string userCreds = System.Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(proxyUri.UserInfo)); basicAuth = "\r\nProxy-Authorization: Basic " + userCreds; }