From 1cecea641489a7b2575f4e552ed1fa7b9562ce89 Mon Sep 17 00:00:00 2001 From: Jason Larke Date: Tue, 10 Mar 2020 12:02:30 +0800 Subject: [PATCH 1/2] 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. --- src/Renci.SshNet/Netconf/NetConfSession.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Renci.SshNet/Netconf/NetConfSession.cs b/src/Renci.SshNet/Netconf/NetConfSession.cs index 14ba00a6e..360a965d0 100644 --- a/src/Renci.SshNet/Netconf/NetConfSession.cs +++ b/src/Renci.SshNet/Netconf/NetConfSession.cs @@ -131,7 +131,10 @@ protected override void OnDataReceived(byte[] data) 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); + var xpath = "/nc:hello/nc:capabilities/nc:capability[text()='urn:ietf:params:netconf:base:1.1']"; + + _usingFramingProtocol = ServerCapabilities.SelectSingleNode(xpath, nsMgr) != null + && ClientCapabilities.SelectSingleNode(xpath, nsMgr) != null; _serverCapabilitiesConfirmed.Set(); } From 0157a2df6fbb2bcb9199cabc50c378965b246992 Mon Sep 17 00:00:00 2001 From: Rob Hague Date: Sun, 16 Jun 2024 10:54:14 +0200 Subject: [PATCH 2/2] add comment --- src/Renci.SshNet/Netconf/NetConfSession.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Renci.SshNet/Netconf/NetConfSession.cs b/src/Renci.SshNet/Netconf/NetConfSession.cs index 1e39ec252..b6da47799 100644 --- a/src/Renci.SshNet/Netconf/NetConfSession.cs +++ b/src/Renci.SshNet/Netconf/NetConfSession.cs @@ -152,6 +152,9 @@ protected override void OnDataReceived(byte[] data) 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;