Skip to content

Commit afa01dc

Browse files
committed
docs: update component signing documentation for OpenSSH key generation
- Replace misleading wasm_keygen with openssh_format=True examples - Add proper ssh_keygen rule usage from openssh Bazel module - Document two distinct key generation methods (OpenSSH vs compact) - Add comprehensive examples showing both approaches - Update troubleshooting section with correct usage patterns - Add MODULE.bazel dependency requirement for openssh module Fixes the documentation to match the actual OpenSSH key generation implementation that resolves wasmsign2 signing issues.
1 parent a4fe32f commit afa01dc

File tree

2 files changed

+104
-24
lines changed

2 files changed

+104
-24
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ jobs:
115115
-//examples/wasm_signing/... \
116116
-//test_examples/... \
117117
-//test_wit_deps/... \
118+
-//examples/oci_publishing:secure_publish_enterprise \
119+
-//examples/oci_publishing:hello_oci_openssh_signed_image \
118120
-//...:*_host
119121
120122
- name: Run Tests
@@ -199,6 +201,8 @@ jobs:
199201
-//examples/wasm_signing/... \
200202
-//test_examples/... \
201203
-//test_wit_deps/... \
204+
-//examples/oci_publishing:secure_publish_enterprise \
205+
-//examples/oci_publishing:hello_oci_openssh_signed_image \
202206
-//...:*_host
203207
204208
- name: Run Tests

docs-site/src/content/docs/security/component-signing.mdx

Lines changed: 100 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ graph TD
4242

4343
```python title="BUILD.bazel"
4444
load("@rules_wasm_component//wasm:defs.bzl", "wasm_keygen")
45+
load("@rules_wasm_component//wasm:ssh_keygen.bzl", "ssh_keygen")
4546

46-
# Generate OpenSSH format keys (compatible with GitHub)
47-
wasm_keygen(
47+
# Generate actual OpenSSH Ed25519 keys (compatible with GitHub)
48+
ssh_keygen(
4849
name = "production_keys",
49-
openssh_format = True,
50+
key_type = "ed25519",
51+
comment = "Production WebAssembly component signing key",
5052
)
5153

5254
# Generate compact format keys (optimal performance)
@@ -119,13 +121,31 @@ bazel build //:validate_signed_component
119121

120122
## Key Management
121123

124+
### Key Generation Methods
125+
126+
There are two distinct approaches to generating signing keys:
127+
128+
**Method 1: Actual OpenSSH Keys (Recommended)**
129+
- Uses real `ssh-keygen` from the openssh Bazel module
130+
- Generates authentic OpenSSH Ed25519 keys
131+
- Compatible with GitHub SSH keys and existing infrastructure
132+
- Required for wasmsign2's `-Z` flag (OpenSSH signing mode)
133+
- Requires `bazel_dep(name = "openssh", version = "9.9p1.bcr.1")` in MODULE.bazel
134+
135+
**Method 2: wasmsign2 Compact Keys**
136+
- Uses wasmsign2's built-in key generation
137+
- Generates compact format keys optimized for WebAssembly signing
138+
- Smaller key size and faster verification
139+
- Native wasmsign2 format
140+
122141
### Key Generation Options
123142

124143
**OpenSSH Format (Recommended for CI/CD):**
125144
```python
126-
wasm_keygen(
145+
ssh_keygen(
127146
name = "github_compatible_keys",
128-
openssh_format = True, # Ed25519 format
147+
key_type = "ed25519", # Actual OpenSSH Ed25519 format
148+
comment = "GitHub compatible signing key",
129149
# Compatible with GitHub SSH keys
130150
# Easy integration with existing infrastructure
131151
)
@@ -141,13 +161,49 @@ wasm_keygen(
141161
)
142162
```
143163

164+
**Complete Example - Both Key Types:**
165+
```python title="BUILD.bazel"
166+
load("@rules_wasm_component//wasm:defs.bzl", "wasm_keygen", "wasm_sign")
167+
load("@rules_wasm_component//wasm:ssh_keygen.bzl", "ssh_keygen")
168+
169+
# OpenSSH keys for production/GitHub integration
170+
ssh_keygen(
171+
name = "production_openssh_keys",
172+
key_type = "ed25519",
173+
comment = "Production WebAssembly signing key",
174+
)
175+
176+
# Compact keys for performance-optimized scenarios
177+
wasm_keygen(
178+
name = "development_compact_keys",
179+
openssh_format = False,
180+
)
181+
182+
# Sign with OpenSSH keys (uses -Z flag internally)
183+
wasm_sign(
184+
name = "openssh_signed_component",
185+
component = ":my_component",
186+
keys = ":production_openssh_keys",
187+
detached = True,
188+
)
189+
190+
# Sign with compact keys (standard wasmsign2)
191+
wasm_sign(
192+
name = "compact_signed_component",
193+
component = ":my_component",
194+
keys = ":development_compact_keys",
195+
detached = False,
196+
)
197+
```
198+
144199
### Key Storage Best Practices
145200

146201
**Development Environment:**
147202
```python
148-
wasm_keygen(
203+
ssh_keygen(
149204
name = "dev_keys",
150-
openssh_format = True,
205+
key_type = "ed25519",
206+
comment = "Development signing key",
151207
# Keys generated in bazel-bin/
152208
# Safe for development use
153209
)
@@ -169,14 +225,20 @@ wasm_sign(
169225

170226
### GitHub Integration
171227

172-
**Using GitHub SSH Keys:**
228+
**Using OpenSSH Keys for Signing:**
173229
```python
174-
# Verify using your GitHub account's SSH keys
175-
wasm_verify(
176-
name = "verify_with_github",
177-
signed_component = ":signed_component",
178-
github_account = "your-username",
179-
# Automatically fetches public keys from GitHub
230+
# Generate OpenSSH keys and use for signing
231+
ssh_keygen(
232+
name = "github_style_keys",
233+
key_type = "ed25519",
234+
comment = "your-username@github",
235+
)
236+
237+
wasm_sign(
238+
name = "github_signed_component",
239+
component = ":my_component",
240+
keys = ":github_style_keys",
241+
detached = True,
180242
)
181243
```
182244

@@ -236,27 +298,27 @@ wasm_sign(
236298

237299
**Development, Staging, Production:**
238300
```python
239-
# Development signing
301+
# Development signing (compact keys)
240302
wasm_sign(
241303
name = "dev_signed",
242304
component = ":component",
243305
keys = ":dev_keys",
244306
detached = False,
245307
)
246308

247-
# Staging signing
309+
# Staging signing (OpenSSH keys)
248310
wasm_sign(
249311
name = "staging_signed",
250312
component = ":component",
251-
keys = ":staging_keys",
313+
keys = ":staging_openssh_keys",
252314
detached = True,
253315
)
254316

255-
# Production signing
317+
# Production signing (OpenSSH keys)
256318
wasm_sign(
257319
name = "prod_signed",
258320
component = ":component",
259-
keys = ":production_keys",
321+
keys = ":production_openssh_keys",
260322
detached = True,
261323
# Additional security for production
262324
)
@@ -464,15 +526,17 @@ wac_compose_with_oci(
464526
**Planned Key Rotation:**
465527
```python
466528
# Current production keys
467-
wasm_keygen(
529+
ssh_keygen(
468530
name = "prod_keys_v1",
469-
openssh_format = True,
531+
key_type = "ed25519",
532+
comment = "Production keys v1",
470533
)
471534

472535
# Next generation keys
473-
wasm_keygen(
536+
ssh_keygen(
474537
name = "prod_keys_v2",
475-
openssh_format = True,
538+
key_type = "ed25519",
539+
comment = "Production keys v2",
476540
)
477541

478542
# Support both during rotation period
@@ -514,8 +578,20 @@ genrule(
514578
**Issue 1: Key format mismatch**
515579
```bash
516580
# Error: Unsupported key format
517-
# Solution: Check openssh_format setting
581+
# Solution: Check if using ssh_keygen vs wasm_keygen correctly
518582
bazel build //keys:signing_keys --verbose_failures
583+
584+
# For OpenSSH keys, use ssh_keygen:
585+
ssh_keygen(
586+
name = "openssh_keys",
587+
key_type = "ed25519",
588+
)
589+
590+
# For compact keys, use wasm_keygen:
591+
wasm_keygen(
592+
name = "compact_keys",
593+
openssh_format = False,
594+
)
519595
```
520596

521597
**Issue 2: Permission denied on key files**

0 commit comments

Comments
 (0)