libssh2: use non-deprecated libssh2_knownhost_addc()#21866
Conversation
Supported since libssh2 v1.2.5. Replacing `libssh2_knownhost_add()`, which was deprecated in that same version. The new API supports a comment field.
There was a problem hiding this comment.
Pull request overview
This PR updates curl’s libssh2 SSH known-host handling to use the non-deprecated libssh2_knownhost_addc() API (deprecated replacement for libssh2_knownhost_add()), enabling support for the newer signature that includes a comment field.
Changes:
- Replace
libssh2_knownhost_add()withlibssh2_knownhost_addc()when adding an accepted (but mismatching) host key into the in-memory known-hosts list.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| NULL, 0, | ||
| LIBSSH2_KNOWNHOST_TYPE_PLAIN | | ||
| LIBSSH2_KNOWNHOST_KEYENC_RAW | | ||
| keybit, NULL); |
There was a problem hiding this comment.
Shouldn't this also provide the port number for the host name? Otherwise the change does not seem to do anything different?
There was a problem hiding this comment.
I meant this to avoid the deprecation warning after merging the patch over at libssh2.
Port should be added, yes, I was thinking in a separate PR.
Is there a buffer/internal API to pick the host:port string, to avoid reinventing it locally?
There was a problem hiding this comment.
I think this libssh2 API also needs the hostname within [ brackets ], so no there is no existing function that provides exactly this.
Supported since libssh2 v1.2.5. Replacing
libssh2_knownhost_add(),which was deprecated in that same version.
The new API supports a comment field.
Ref: libssh2/libssh2#1977