Quick start
Enable HTTPS by providing SSL certificate options:https://localhost:8443/mcp.
SSL options
string
required
Path to the SSL certificate file (PEM format)
string
required
Path to the SSL private key file (PEM format)
string
Path to the CA certificate for mutual TLS authentication (optional)
Development setup
For local development and testing, you can generate self-signed certificates:1
Generate self-signed certificates
Use OpenSSL to create a self-signed certificate:This creates:
key.pem- Private keycert.pem- Self-signed certificate valid for 365 days
2
Configure your server
3
Accept self-signed certificate
When connecting from a client, you’ll need to accept the self-signed certificate warning. This is normal for development.
Production setup
For production, use certificates from a trusted Certificate Authority (CA).Using Let’s Encrypt
Let’s Encrypt provides free SSL certificates:1
Install Certbot
2
Obtain certificate
/etc/letsencrypt/live/your-domain.com/fullchain.pem(certificate)/etc/letsencrypt/live/your-domain.com/privkey.pem(private key)
3
Configure server
4
Set up auto-renewal
Let’s Encrypt certificates expire after 90 days. Set up automatic renewal:
Using commercial certificates
If you have certificates from a commercial CA (DigiCert, GlobalSign, etc.):Mutual TLS (mTLS)
For enhanced security, require clients to present valid certificates:1
Generate client certificates
2
Configure server with CA
3
Connect with client certificate
Clients must present a certificate signed by the specified CA to connect.
Complete example
Here’s a production-ready HTTPS server with proper error handling:Security best practices
1
Use strong cipher suites
Configure Node.js to use strong cipher suites:
2
Keep certificates secure
- Store private keys with restricted permissions (chmod 600)
- Never commit certificates to version control
- Use environment variables for certificate paths
- Consider using a secrets management service (AWS Secrets Manager, HashiCorp Vault)
3
Enable HSTS
Force HTTPS connections using HTTP Strict Transport Security:
4
Monitor certificate expiration
Set up alerts to renew certificates before they expire:
Troubleshooting
Error: ENOENT - Certificate file not found
Error: ENOENT - Certificate file not found
Verify the file paths are correct and the files exist:
Error: ERR_SSL_PROTOCOL_ERROR
Error: ERR_SSL_PROTOCOL_ERROR
This usually means:The MD5 hashes should match.
- The certificate and key don’t match
- The certificate is invalid or expired
- Wrong certificate format (should be PEM)
Self-signed certificate warnings
Self-signed certificate warnings
Browsers and clients will warn about self-signed certificates. For development:
- Accept the warning (temporary)
- Add certificate to system trust store (better)
Next steps
Production Deployment
Learn about production deployment best practices
Authentication
Add authentication to your HTTPS server