Browse Source

test on azure passed

Robert 1 year ago
parent
commit
6695ec7764
1 changed files with 7 additions and 5 deletions
  1. 7 5
      EVCB_OCPP.WSServer/Service/WsService/OcppWebsocketService.cs

+ 7 - 5
EVCB_OCPP.WSServer/Service/WsService/OcppWebsocketService.cs

@@ -189,14 +189,16 @@ public class OcppWebsocketService : WebsocketService<WsClientData>
             }
 
             X509Certificate2 clientCertificate = null;
-            if (context.Request.Headers.ContainsKey("X-ARR-ClientCert"))
+            if (clientCertificate is null &&
+                context.Connection.ClientCertificate is not null)
             {
-                byte[] bytes = Encoding.ASCII.GetBytes(context.Request.Headers["X-ARR-ClientCert"]);
-                clientCertificate = new X509Certificate2(bytes);
+                clientCertificate = context.Connection.ClientCertificate;
             }
-            if (context.Connection.ClientCertificate is not null)
+            if (clientCertificate is null &&
+                context.Request.Headers.TryGetValue("X-ARR-ClientCert", out var clientCertString))
             {
-                clientCertificate = context.Connection.ClientCertificate;
+                byte[] bytes = Convert.FromBase64String(clientCertString);
+                clientCertificate = new X509Certificate2(bytes);
             }
             if (clientCertificate is  null)
             {