Conversation
Record the plain host key and verified OpenSSH certificate after certificate-based host authentication succeeds. Make OpenSshCertificate and its read accessors public so applications can inspect the certificate. Keep the certificate unset when plain-key fallback is used, and cover both certificate and plain-key authentication paths.
|
|
What's the purpose of this? |
Nvm, let me think on this some more. |
| * @return the verified host certificate, or {@code null} if none was used | ||
| * @see #getHostKey() | ||
| */ | ||
| public OpenSshCertificate getHostKeyCertificate() { |
There was a problem hiding this comment.
I am opposed to making the OpenSshCertificate class a part of the public API.
There was a problem hiding this comment.
👍 Thanks for the feedback! Let me know if you think the certificate information can be exposed in some other way and I'll try that out. Otherwise I'll close this PR as a wont do.
There was a problem hiding this comment.
I need to think through this some more to try and think of a solution that wouldn't leak the internal OpenSshCertificate class.
|
FYI, I haven't forgotten about this and am working on an alternative solution. |
|
Hi @fornwall, Just wanted to update you that I haven't forgotten about this. Thanks, |



Summary
Expose the verified OpenSSH host certificate through
Session#getHostKeyCertificate().Successful certificate verification currently returns from
Session#checkHostbeforedoCheckHostKey, leavingSession#getHostKey()unset and the certificate inaccessible to callers. This change:Session#getHostKey();Session#getHostKeyCertificate();OpenSshCertificateand its read accessors public.getHostKeyCertificate()remainsnullfor plain host-key authentication and when certificate verification fails buthost_certificate_to_key_fallbackaccepts the underlying key.Tests
./mvnw -B -DskipITs=false -Dit.test=HostCertificateIT verifyHostCertificateITtests passedDisclaimar: Created with claude code and opus 5, reviewed by me.