Add OpenSSH certificate user authentication#1060
Open
yosuke-wolfssl wants to merge 1 commit into
Open
Conversation
2576e03 to
1c40cc1
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1060
Scan targets checked: wolfssh-bugs, wolfssh-src
No new issues found in the changed files. ✅
1c40cc1 to
c00d111
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add OpenSSH certificate user authentication
Adds support for authenticating users with OpenSSH certificates
(
*-cert-v01@openssh.com) in wolfSSHd, behind a new--enable-ossh-certsconfigure option (also enabled by
--enable-all).Motivation
OpenSSH certificates let an operator authorize users by trusting a single CA
(via
TrustedUserCAKeys) instead of distributing every user's public key intoauthorized_keys. This brings wolfSSHd in line with stock OpenSSHsshdforcertificate-based user auth.
What's implemented (Unix)
Library (
src/ossh.c,src/internal.c) — portable, no platform deps:certificate (RSA incl.
rsa-sha2-256/512, ECDSA P-256/P-384/P-521, Ed25519).force-commandandsource-address; tolerate unknown extensions.against it (proving possession of the certified private key), using the
on-the-wire signed length so it works with the reconstructed key.
caKey,principals, validity,source-address,force-command) are handed to the user-auth callback for enforcement.Daemon (
apps/wolfsshd/auth.c,wolfsshd.c) —CheckPublicKeyUnixenforces,fail-closed and in order:
TrustedUserCAKeys.principal-less certificate is rejected, matching OpenSSH
sshd).valid_after/valid_before.force-commandoverrides therequested command for shell, exec, SFTP, and SCP sessions
(
internal-sftpstill permits SFTP).Security model
its embedded CA) and that the client holds the certified private key. It
does not decide trust — that is the application callback's responsibility
(check
caKeyagainst a trust store, bind the principal, enforcevalidity/source-address). This mirrors how regular public-key auth delegates
the
authorized_keyscheck.Configuration
./configure --enable-ossh-certs --enable-sshd # or --enable-allPlatform support
on the Windows threaded path. Follow-up work is planned in two PRs
(per-connection cert-state relocation, then Windows enforcement + a Windows CI
cert-auth job).
Testing
tests/api.c— certificate parse, CA-signature verify, andcritical-option/extension handling (self-contained binary vectors).
tests/unit.c— Ed25519 public-key parse and the user-signaturewire-length path (wire-derived length equals the legacy field-sum).
apps/wolfsshd/test/test_configuration.c— direct unit tests for theenforcement helpers (principal binding incl. empty-list rejection, validity
window, source-address CIDR/prefix matching).
apps/wolfsshd/test/sshd_ossh_cert_test.sh— end-to-end against both thewolfSSH example client and the system OpenSSH client: valid cert (Ed25519/RSA/
ECDSA CAs and user keys), untrusted CA, wrong principal, empty principal,
expired cert, unknown critical option, source-address match/deny,
force-command,
internal-sftp, and SFTP/SCP force-command gating.--enable-allcompiles the option in; the e2e runs viarun_all_sshd_tests.sh).Known limitations
!entry) is not implemented; a negated entryfails the whole list closed (denies) and logs the offending entry.
wolfSSH_CTX_UseOsshCert_bufferreturns
WS_UNIMPLEMENTED_E.Notes for reviewers
WS_UserAuthData_PublicKeyare appended after theexisting members so the default (
WOLFSSH_OSSH_CERTSdisabled) struct layoutis unchanged; enabling the option changes the layout, so the app and library
must be built with the same setting.
src/ossh.cis added to the Windows MSVC project (wolfssh.vcxproj) becausethe OpenSSH key decoders it defines are referenced unconditionally.