Repository navigation
Description
Summary
Add WebID-TLS (mutual TLS / client certificate) authentication to JSS, enabling backend services, CLI tools, and automated agents to authenticate without user interaction.
Background
What is WebID-TLS?
WebID-TLS is a decentralized authentication protocol that uses TLS client certificates:
- Client presents X.509 certificate during TLS handshake
- Certificate's
SubjectAlternativeName(SAN) contains a WebID URI - Server fetches the WebID profile document
- Server verifies the certificate's public key matches the one published in the profile
sequenceDiagram
participant C as Client
participant S as JSS Server
participant P as WebID Profile
C->>S: TLS Handshake + Client Cert
Note over S: Extract WebID from SAN
S->>P: Fetch WebID Profile
P-->>S: Profile with cert:key
Note over S: Match modulus + exponent
S-->>C: Authenticated as WebID
Why Now?
The W3C Linked Web Storage Use Cases group has raised this need for enterprise adoption:
"As a large tax advisory office, I want our existing backend services to authenticate themselves (without user interaction), such that these services can fetch and crunch private data from our clients."
Key drivers:
- Enterprise adoption: Organizations with existing PKI/mTLS infrastructure want seamless LWS integration
- Backend services: Server-to-server communication doesn't need browser UX
- IoT/Agents: Automated systems need non-interactive authentication
- CLI tools: Developers using
curlor custom tools with client certs
Browser Support Note
While browser support for in-browser certificate generation (<keygen>) has been removed from Chrome and deprecated in Firefox, this does not affect server-side WebID-TLS:
- Server-to-server: Works perfectly with standard mTLS
- CLI tools:
curl --certworks fine - Browser workarounds: YouID extension available
Implementation Guide
Files to Create/Modify
| File | Purpose |
|---|---|
src/auth/webid-tls.js |
WebID-TLS authentication module |
src/server.js |
Enable requestCert option on HTTPS server |
src/config.js |
Add --webid-tls CLI flag |
Step 1: Server Configuration
Modify src/server.js to request client certificates:
// In createServer, when SSL is enabled
if (options.ssl && options.ssl.key && options.ssl.cert) {
const httpsOptions = {
key: options.ssl.key,
cert: options.ssl.cert,
// Enable WebID-TLS
requestCert: options.webidTls || false, // Request client cert
rejectUnauthorized: false // Don't reject self-signed (we verify via WebID)
};
// ... create HTTPS server
}Step 2: Create WebID-TLS Auth Module
Create src/auth/webid-tls.js:
import { graph, SPARQLToQuery } from 'rdflib';
const SPARQL_QUERY = `
PREFIX cert: <http://www.w3.org/ns/auth/cert#>
SELECT ?webid ?m ?e WHERE {
?webid cert:key ?key .
?key cert:modulus ?m .
?key cert:exponent ?e .
}
`;
/**
* Extract WebID from client certificate's SubjectAlternativeName
*/
export function getWebIdFromCert(certificate) {
if (!certificate?.subjectaltname) return null;
const match = certificate.subjectaltname.match(/URI:([^,\s]+)/);
return match ? match[1] : null;
}
/**
* Verify certificate public key matches WebID profile
*/
export async function verifyWebIdTls(certificate, webId) {
if (!certificate.modulus || !certificate.exponent) {
throw new Error('Certificate missing modulus or exponent');
}
// Fetch WebID profile
const response = await fetch(webId, {
headers: { 'Accept': 'text/turtle, application/ld+json' }
});
if (!response.ok) {
throw new Error(`Failed to fetch WebID profile: ${response.status}`);
}
const body = await response.text();
const contentType = response.headers.get('content-type')?.split(';')[0];
// Parse profile and find matching key
const g = graph();
// ... parse RDF and run SPARQL query
const certModulus = certificate.modulus.toLowerCase();
const certExponent = parseInt(certificate.exponent, 16).toString();
// Match modulus and exponent from profile
// Return true if match found, false otherwise
}
/**
* Middleware to authenticate via WebID-TLS
*/
export async function webIdTlsAuth(request) {
const socket = request.raw?.socket || request.socket;
if (!socket?.getPeerCertificate) {
return null; // Not a TLS connection
}
const cert = socket.getPeerCertificate();
if (!cert || Object.keys(cert).length === 0) {
return null; // No client certificate
}
const webId = getWebIdFromCert(cert);
if (!webId) {
return null; // No WebID in certificate
}
const verified = await verifyWebIdTls(cert, webId);
return verified ? webId : null;
}Step 3: Integrate with Auth Flow
In src/auth/token.js, add WebID-TLS as authentication method:
import { webIdTlsAuth } from './webid-tls.js';
export async function getWebIdFromRequestAsync(request) {
// Try bearer token first
let webId = await getWebIdFromToken(request);
// Fall back to WebID-TLS
if (!webId) {
webId = await webIdTlsAuth(request);
}
return { webId };
}Step 4: CLI Configuration
Add to src/config.js:
.option('--webid-tls', 'Enable WebID-TLS client certificate authentication')Testing
Manual Testing with curl
# Generate self-signed cert with WebID in SAN
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 \
-subj "/CN=Test" -addext "subjectAltName=URI:https://example.com/profile/card#me"
# Test authentication
curl --cert cert.pem --key key.pem https://localhost:8443/private/resourceUnit Tests
describe('WebID-TLS Authentication', () => {
it('should extract WebID from certificate SAN', () => {
const cert = { subjectaltname: 'URI:https://alice.example/card#me' };
expect(getWebIdFromCert(cert)).toBe('https://alice.example/card#me');
});
it('should verify certificate against WebID profile', async () => {
// Mock profile with matching cert:key
// Verify returns true
});
it('should reject mismatched certificate', async () => {
// Mock profile with different key
// Verify returns false
});
});WebID Profile Requirements
For WebID-TLS to work, the WebID profile must contain the certificate's public key:
@prefix cert: <http://www.w3.org/ns/auth/cert#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<#me> cert:key [
a cert:RSAPublicKey;
cert:modulus "abc123..."^^xsd:hexBinary;
cert:exponent 65537
] .Use Cases Enabled
- Backend Services: Tax advisors fetching client data (W3C use case)
- CLI Tools: Developers using
curlor custom scripts - IoT Devices: Sensors/actuators with embedded certificates
- Automated Agents: Bots and crawlers with verifiable identity
- Legacy Integration: Organizations with existing PKI infrastructure
References
- WebID-TLS Spec
- W3C LWS-UCS Issue #40 - Enterprise use case
- Solid Protocol - WebID-TLS
- NSS WebID-TLS Implementation
- YouID Browser Extension
Related
- Solid-OIDC (current default auth) remains primary for browser-based apps
- WebID-TLS would be an additional authentication method, not a replacement
Activity
melvincarvalho commentedon Jan 8, 2026
Note: did:nostr + TLS Client Certificates
An interesting extension would be supporting
did:nostrwith TLS client certificates. This would be elegant because did:nostr is self-certifying - the public key IS the identifier, so there's no need for external verification.The secp256k1 Challenge
However, there's a curve compatibility issue:
Nostr uses secp256k1 (same as Bitcoin), but TLS 1.3 dropped support for this curve. This means native did:nostr + mTLS would require forcing TLS 1.2.
Potential Workarounds
Recommendation
For did:nostr authentication, HTTP Signatures or NIP-98 (HTTP Auth) may be more practical than mTLS since they work with TLS 1.3 and leverage the existing Nostr key directly.
References:
melvincarvalho commentedon May 9, 2026
For context: WebID-TLS is the existing precedent for 'profile declares its keys' (
cert:key/cert:modulus). The design in #386 generalises this pattern under W3C CID v1'sverificationMethod+Multikey/JsonWebKey— same shape, broader cryptographic scope.melvincarvalho commentedon Jun 10, 2026
Closing as shipped: WebID-TLS landed (v0.0.75 era) —
src/auth/webid-tls.js,--webid-tls/--no-webid-tlsCLI flags, README feature bullet. Known defects are tracked separately and stay open: #70 (Accept-header priority for profile fetch, strict data-island regex, @id references not dereferenced) — closing this feature-request issue does not close those. Anyone picking up WebID-TLS work should start at #70.