From 0effbd7b5159ddc8a52c57398e7ae1bc2a802f19 Mon Sep 17 00:00:00 2001 From: declspec Date: Sun, 16 Jun 2024 17:39:31 +0800 Subject: [PATCH] Updated NETCONF framing protocol detection to check both client & server capabilities (#639) * Updated NETCONF framing protocol detection to check both client & server capabilities This fixes an issue where the NetConfSession would expect the framing protocol to be used if ServerCapabilities contained 1.1, however the server would actually be using the legacy protocol as the client only advertises support for 1.0. * add comment --------- Co-authored-by: Jason Larke Co-authored-by: Rob Hague --- src/Renci.SshNet/Netconf/NetConfSession.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Renci.SshNet/Netconf/NetConfSession.cs b/src/Renci.SshNet/Netconf/NetConfSession.cs index aca2f8e0..b6da4779 100644 --- a/src/Renci.SshNet/Netconf/NetConfSession.cs +++ b/src/Renci.SshNet/Netconf/NetConfSession.cs @@ -150,7 +150,13 @@ namespace Renci.SshNet.NetConf var nsMgr = new XmlNamespaceManager(ServerCapabilities.NameTable); nsMgr.AddNamespace("nc", "urn:ietf:params:xml:ns:netconf:base:1.0"); - _usingFramingProtocol = ServerCapabilities.SelectSingleNode("/nc:hello/nc:capabilities/nc:capability[text()='urn:ietf:params:netconf:base:1.1']", nsMgr) != null; + const string xpath = "/nc:hello/nc:capabilities/nc:capability[text()='urn:ietf:params:netconf:base:1.1']"; + + // This will currently evaluate to false since we (the client) do not advertise 1.1 capability. + // Despite some code existing for the 1.1 framing protocol, it is thought to be incorrect or + // incomplete. The NETCONF code is practically untested at the time of writing. + _usingFramingProtocol = ServerCapabilities.SelectSingleNode(xpath, nsMgr) != null + && ClientCapabilities.SelectSingleNode(xpath, nsMgr) != null; _ = _serverCapabilitiesConfirmed.Set(); }