dotnet-devcert-trust
Diagnose and fix .NET HTTPS dev certificate trust issues on Linux. Covers the full certificate lifecycle from generation to system CA bundle inclusion, with distro-specific guidance for Ubuntu, Fedora, Arch, and WSL2.
What this skill does
# .NET Dev Certificate Trust on Linux
## When to Use This Skill
Use this skill when:
- Redis TLS connections fail with `UntrustedRoot` or `RemoteCertificateNameMismatch` in Aspire
- `dotnet dev-certs https --check --trust` returns exit code 7
- HTTPS localhost connections fail with certificate validation errors
- After running `dotnet dev-certs https --clean` and needing to restore trust
- Setting up a new Linux dev machine for .NET HTTPS development
- Aspire dashboard or inter-service gRPC calls fail with TLS errors
- Upgrading from Aspire < 13.1.0 (which didn't use TLS on Redis by default)
## The Problem
On Windows and macOS, `dotnet dev-certs https --trust` handles everything automatically — it generates the certificate, installs it in the user store, and adds it to the system trust store. On Linux, **it does almost nothing useful**. The command generates the cert and places it in the user store, but:
1. It does **not** export the certificate to the system CA directory
2. It does **not** run `update-ca-certificates` to rebuild the CA bundle
3. It does **not** add the cert to browser trust stores (NSS/NSSDB)
4. The `--trust` flag silently succeeds but the cert remains untrusted
This means .NET applications, OpenSSL, curl, and browsers all reject the dev certificate — even though `dotnet dev-certs https --check` reports it exists.
### Why This Surfaces with Aspire 13.1.0+
Prior to Aspire 13.1.0, Redis connections used plaintext. Starting with 13.1.0, Aspire enables TLS on Redis by default. If your dev cert isn't trusted at the system level, Redis connections fail immediately with:
```
System.Security.Authentication.AuthenticationException:
The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot
```
## How Linux Certificate Trust Works
Understanding the architecture prevents cargo-cult debugging:
```
┌─────────────────────────────────────────────────────┐
│ Application (.NET, curl, OpenSSL) │
│ reads: /etc/ssl/certs/ca-certificates.crt │
│ (consolidated CA bundle) │
└──────────────────────┬──────────────────────────────┘
│ built by
┌──────────────────────▼──────────────────────────────┐
│ update-ca-certificates │
│ reads from: │
│ /usr/share/ca-certificates/ (distro CAs) │
│ /usr/local/share/ca-certificates/ (local CAs) │
│ writes to: │
│ /etc/ssl/certs/ca-certificates.crt (bundle) │
│ /etc/ssl/certs/*.pem (individual symlinks) │
└─────────────────────────────────────────────────────┘
```
**Key insight:** Placing a `.crt` file in `/usr/local/share/ca-certificates/` is necessary but **not sufficient**. The consolidated bundle at `/etc/ssl/certs/ca-certificates.crt` must be rebuilt by running `update-ca-certificates`. Applications read the bundle, not the individual files.
## 5-Point Diagnostic Procedure
Run these checks in order. Stop at the first FAIL and apply its fix before continuing.
### Check 1: Dev Cert Existence
```bash
dotnet dev-certs https --check
echo "Exit code: $?"
```
| Exit Code | Meaning | Action |
|-----------|---------|--------|
| 0 | Cert exists in user store | PASS — continue |
| Non-zero | No valid dev cert | Run `dotnet dev-certs https` |
### Check 2: System Trust Store — Single Cert, Correct Permissions
```bash
ls -la /usr/local/share/ca-certificates/ | grep -iE 'dotnet|aspnet'
```
| Result | Meaning |
|--------|---------|
| Only `dotnet-dev-cert.crt` with `-rw-r--r--` (644) | PASS |
| Multiple cert files, wrong permissions, or stale `aspnet*` files | FAIL |
**Common stale files from previous sessions:**
| File | Problem |
|------|---------|
| `aspnetcore-dev.crt` | Often created with `0600` permissions (unreadable by `update-ca-certificates`) |
| `aspnet/https.crt` | Old convention, may have a different fingerprint than current dev cert |
| `dotnet-dev-cert.crt` with `0600` | Correct name but wrong permissions |
**Fix:**
```bash
# Remove ALL stale cert files
sudo rm -f /usr/local/share/ca-certificates/aspnetcore-dev.crt
sudo rm -rf /usr/local/share/ca-certificates/aspnet/
# Ensure correct permissions on the dev cert (if it exists)
sudo chmod 644 /usr/local/share/ca-certificates/dotnet-dev-cert.crt
```
### Check 3: CA Bundle Inclusion
This is the most commonly failed check. The cert file exists but was never added to the bundle.
```bash
openssl verify -CAfile /etc/ssl/certs/ca-certificates.crt \
/usr/local/share/ca-certificates/dotnet-dev-cert.crt
```
| Result | Meaning |
|--------|---------|
| `dotnet-dev-cert.crt: OK` | PASS — cert is in the consolidated bundle |
| `error 20 at 0 depth lookup: unable to get local issuer certificate` | FAIL — bundle was never rebuilt |
| `error 2 at 0 depth lookup: unable to get issuer certificate` | FAIL — same issue, different OpenSSL version |
**Fix:**
```bash
sudo update-ca-certificates
# Expected output includes "1 added" or similar
# Re-verify
openssl verify -CAfile /etc/ssl/certs/ca-certificates.crt \
/usr/local/share/ca-certificates/dotnet-dev-cert.crt
```
### Check 4: Environment Variable Overrides
SSL environment variables can redirect certificate lookups away from the system bundle:
```bash
echo "SSL_CERT_DIR=${SSL_CERT_DIR:-<unset>}"
echo "SSL_CERT_FILE=${SSL_CERT_FILE:-<unset>}"
echo "DOTNET_SSL_CERT_DIR=${DOTNET_SSL_CERT_DIR:-<unset>}"
echo "DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=${DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER:-<unset>}"
```
| Result | Meaning |
|--------|---------|
| All `<unset>` | PASS |
| Any variable set | FAIL — may redirect cert lookups |
**Fix:** Remove the offending variables from your shell profile (`~/.bashrc`, `~/.zshrc`, `~/.profile`) and start a new shell.
### Check 5: Symlink Integrity
Stale symlinks from previously removed certificates can confuse OpenSSL:
```bash
find /etc/ssl/certs/ -xtype l 2>/dev/null | head -5
```
| Result | Meaning |
|--------|---------|
| No output | PASS |
| Broken symlinks listed | FAIL |
**Fix:**
```bash
sudo update-ca-certificates --fresh
# Rebuilds ALL symlinks from scratch
```
## Full Recovery Procedure
When multiple checks fail or you want a clean slate, run this complete sequence:
```bash
#!/usr/bin/env bash
set -euo pipefail
echo "=== .NET Dev Certificate Trust Recovery ==="
# Step 1: Remove ALL stale certificate files
echo "--- Removing stale certificate files ---"
sudo rm -f /usr/local/share/ca-certificates/aspnetcore-dev.crt
sudo rm -rf /usr/local/share/ca-certificates/aspnet/
sudo rm -f /usr/local/share/ca-certificates/dotnet-dev-cert.crt
# Step 2: Clean and regenerate dev cert
echo "--- Regenerating dev certificate ---"
dotnet dev-certs https --clean
dotnet dev-certs https
# Step 3: Export as PEM and install to system trust store
echo "--- Installing to system trust store ---"
dotnet dev-certs https --export-path /tmp/dotnet-dev-cert.crt --format PEM --no-password
sudo cp /tmp/dotnet-dev-cert.crt /usr/local/share/ca-certificates/dotnet-dev-cert.crt
sudo chmod 644 /usr/local/share/ca-certificates/dotnet-dev-cert.crt
rm /tmp/dotnet-dev-cert.crt
# Step 4: Rebuild CA bundle (CRITICAL — most commonly missed step)
echo "--- Rebuilding CA bundle ---"
sudo update-ca-certificates
# Step 5: Verify
echo "--- Verifying ---"
openssl verify -CAfile /etc/ssl/certs/ca-certificates.crt \
/usr/local/share/ca-certificates/dotnet-dev-cert.crt
echo "=== Done! Restart your .NET application. ==="
```
Save this as `~/fix-devcert.sh` and run with `bash ~/fix-devcert.sh` when needed.
## Distro-Specific Notes
### Ubuntu / Debian
The procedure above is written for Ubuntu/Debian and works as-is.
- **CA directory:** `/usr/local/share/ca-certificates/`
- **Bundle command:** `sudo update-ca-certificates`
- **Bundle output:** `/etc/ssl/certs/ca-certificates.crt`
- **Cert format:** PEM with `.crt` extension required
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.