Parcourir la source

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 <jason.larke@curtin.edu.au>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
declspec il y a 1 an
Parent
commit
0effbd7b51
1 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 7 1
      src/Renci.SshNet/Netconf/NetConfSession.cs

+ 7 - 1
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();
             }