Certificate Management in RouterOS: A Complete Guide
Certificate Management in RouterOS: A Complete Guide
Section titled âCertificate Management in RouterOS: A Complete GuideâRouterOS Version: 7.x+ Difficulty: Intermediate Estimated Time: 45 minutes
Overview
Section titled âOverviewâCertificates are the foundation of secure communication in modern networks. RouterOS provides comprehensive PKI (Public Key Infrastructure) capabilities for generating, signing, importing, and managing X.509 certificates. Youâll use certificates for:
- HTTPS Management - Secure web interface (www-ssl)
- VPN Authentication - IPsec IKEv2, OpenVPN, SSTP, WireGuard
- Wireless Security - EAP-TLS for 802.1X/Dot1X
- API Security - Encrypted API connections (api-ssl)
- Secure Fetching - HTTPS downloads with certificate verification
RouterOS v7 includes Letâs Encrypt integration for automated SSL certificate provisioning, plus built-in root CA trust anchors (v7.19+) so you can verify external certificates without manual imports.
Key limitation: Certificate operations require accurate system time. Always configure NTP before working with certificates.
Certificate Concepts
Section titled âCertificate ConceptsâThe PKI Triangle
Section titled âThe PKI Triangleâââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ Certificate Authority (CA) ââ Issues and signs certificates ââ (Self-signed root of trust) ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ â â Signs âźâââââââââââââââââââââââââ ââââââââââââââââââââââââââ Server Certificate â â Client Certificate ââ Proves server identity â â Proves client identity ââ (www-ssl, VPN server) â â (VPN client, EAP-TLS) ââââââââââââââââââââââââââ âââââââââââââââââââââââââTrust chain: When a client connects to your server, it verifies:
- Server certificate is signed by a trusted CA
- Certificate hasnât expired
- Certificate matches the serverâs hostname/IP
Certificate vs Template
Section titled âCertificate vs TemplateâIn RouterOS, you first create a template (unsigned certificate request), then sign it to create a usable certificate:
Template (unsigned) ââsignâââś Certificate (usable)Templates are automatically deleted after signing. This is by designâyou work with the signed certificate, not the template.
Menu Reference
Section titled âMenu Referenceâ| Menu | Purpose |
|---|---|
/certificate | Certificate management |
/certificate/settings | CRL and trust settings |
/certificate/scep-server | SCEP enrollment server |
Certificate Properties
Section titled âCertificate PropertiesâTemplate Properties (when creating)
Section titled âTemplate Properties (when creating)â| Property | Type | Default | Description |
|---|---|---|---|
name | string | - | Certificate name (required) |
common-name | string | - | Certificate CN - typically hostname (required) |
country | string | - | Country code (e.g., âUSâ) |
state | string | - | State/Province |
locality | string | - | City |
organization | string | - | Organization name |
unit | string | - | Organizational Unit |
subject-alt-name | list | - | Alternative names (DNS:, IP:, email:) |
key-size | integer/curve | 2048 | Key size or EC curve |
key-usage | flags | see below | Certificate usage permissions |
days-valid | integer | 365 | Validity period after signing |
digest-algorithm | enum | sha256 | Hash algorithm |
trusted | yes/no | no | Trust for verification |
Key Size Options
Section titled âKey Size Optionsâ| Type | Options |
|---|---|
| RSA | 1024, 1536, 2048, 4096, 8192 |
| EC | prime256v1, secp384r1, secp521r1 |
Recommendation: Use 2048-bit RSA or prime256v1 EC for balance of security and performance.
Key Usage Flags
Section titled âKey Usage Flagsâ| Flag | Description | Typical Use |
|---|---|---|
digital-signature | Sign data | All certificates |
key-encipherment | Encrypt keys | TLS certificates |
data-encipherment | Encrypt data | Less common |
key-cert-sign | Sign other certificates | CA only |
crl-sign | Sign CRLs | CA only |
tls-server | TLS server authentication | Server certificates |
tls-client | TLS client authentication | Client certificates |
Certificate Flags (in print output)
Section titled âCertificate Flags (in print output)â| Flag | Meaning |
|---|---|
| K | Has private key (required for servers) |
| A | Authority (CA certificate) |
| T | Trusted for verification |
| I | Issued by local CA |
| R | Revoked |
| E | Expired |
| L | Has CRL |
Configuration Examples
Section titled âConfiguration ExamplesâExample 1: Create a Self-Signed CA
Section titled âExample 1: Create a Self-Signed CAâCreate your own Certificate Authority to sign certificates:
# Step 1: Create CA template/certificate add name=myCA common-name="My Organization CA" \ key-usage=key-cert-sign,crl-sign days-valid=3650 key-size=2048
# Step 2: Sign to create self-signed CA/certificate sign myCA
# Step 3: Verify CA was created/certificate print where name=myCAExpected output shows flags KAT (private Key, Authority, Trusted).
Example 2: Create Server Certificate for HTTPS
Section titled âExample 2: Create Server Certificate for HTTPSâCreate a certificate for the routerâs web interface:
# Step 1: Create server template with SAN/certificate add name=router-cert common-name=router.example.com \ subject-alt-name=DNS:router.example.com,IP:192.168.1.1 \ key-usage=digital-signature,key-encipherment,tls-server \ days-valid=365
# Step 2: Sign with your CA/certificate sign router-cert ca=myCA
# Step 3: Apply to www-ssl service/ip service set www-ssl certificate=router-cert disabled=no
# Step 4: Verify/ip service print where name=www-sslNow access router at https://192.168.1.1 (browser will warn about untrusted CA unless you import myCA).
Example 3: Letâs Encrypt Certificate (Automated)
Section titled âExample 3: Letâs Encrypt Certificate (Automated)âGet a free, publicly-trusted SSL certificate:
Prerequisites:
- DNS name pointing to routerâs public IP
- Port 80 accessible from internet
- www service can be temporarily enabled
# Option A: Using your own domain/certificate enable-ssl-certificate dns-name=router.example.com
# Option B: Using IP Cloud (automatic DNS)/ip cloud set ddns-enabled=yes# Wait for DNS to propagate, then:/certificate enable-ssl-certificate# Uses <serial>.sn.mynetname.net automaticallyLetâs Encrypt certificates:
- Valid for 90 days
- Auto-renew at 80% validity (72 days)
- Require port 80 accessible at renewal time
Example 4: Create Client Certificate for VPN
Section titled âExample 4: Create Client Certificate for VPNâFor certificate-based VPN authentication:
# Step 1: Create client template/certificate add name=vpn-client1 common-name="VPN User 1" \ key-usage=digital-signature,key-encipherment,tls-client \ days-valid=365
# Step 2: Sign with CA/certificate sign vpn-client1 ca=myCA
# Step 3: Export for distribution/certificate export-certificate vpn-client1 export-passphrase=clientpass type=pkcs12
# Step 4: Export CA (for client trust)/certificate export-certificate myCA file-name=ca-cert
# Step 5: Download from Files menu/file print where name~"cert_export"Give the client both files: the PKCS12 (contains cert + key) and the CA certificate (for trust).
Example 5: Import External Certificate
Section titled âExample 5: Import External CertificateâImport a certificate purchased from a commercial CA:
# Step 1: Upload files to router (via Winbox drag-drop, FTP, or SCP)
# Step 2: Import certificate/certificate import file-name=server.crt
# Step 3: Import private key (if separate file)/certificate import file-name=server.key
# Or import PKCS12 bundle (includes both)/certificate import file-name=server.p12 passphrase=filepassword
# Step 4: Verify import (should show K flag)/certificate printExample 6: Enable Built-in Root CA Trust (v7.19+)
Section titled âExample 6: Enable Built-in Root CA Trust (v7.19+)âAllow RouterOS to verify external HTTPS certificates:
# Enable built-in trust anchors/certificate settings set builtin-trust-anchors=trusted
# Now fetch with certificate verification works/tool fetch url=https://example.com check-certificate=yesThis is required for:
- DNS over HTTPS (DoH)
- Secure HTTPS fetches
- Cloud service connections
Example 7: Certificate for OpenVPN Server
Section titled âExample 7: Certificate for OpenVPN Serverâ# Step 1: Create server certificate/certificate add name=ovpn-server common-name=vpn.example.com \ subject-alt-name=DNS:vpn.example.com,IP:203.0.113.1 \ key-usage=digital-signature,key-encipherment,tls-server \ days-valid=365
# Step 2: Sign with CA/certificate sign ovpn-server ca=myCA
# Step 3: Apply to OpenVPN/interface ovpn-server server set certificate=ovpn-server \ require-client-certificate=yesExample 8: Export and Backup Certificates
Section titled âExample 8: Export and Backup Certificatesâ# Export CA certificate only (for distribution)/certificate export-certificate myCA file-name=my-ca-public
# Export certificate with private key (for backup)/certificate export-certificate router-cert export-passphrase=backuppass type=pkcs12
# List exported files/file print where name~"cert"Export types:
pem- PEM format (default, certificate only)pkcs12- PKCS#12 bundle (certificate + key, encrypted)
CRL (Certificate Revocation List)
Section titled âCRL (Certificate Revocation List)âEnable CRL checking to reject revoked certificates:
# Enable CRL checking/certificate settings set crl-use=yes crl-download=yes
# Check current settings/certificate settings printNote: CRL checking requires:
- HTTP access to CRL distribution points
- Complete certificate chain imported
Subject Alternative Names (SAN)
Section titled âSubject Alternative Names (SAN)âModern certificates should include SANs for all ways the server is accessed:
/certificate add name=multi-access common-name=router.example.com \ subject-alt-name=DNS:router.example.com,DNS:router.lan,IP:192.168.1.1,IP:10.0.0.1SAN formats:
DNS:hostname.example.comIP:192.168.1.1email:[email protected]
Common Problems and Solutions
Section titled âCommon Problems and SolutionsâProblem 1: âTemplates are not exportable!â
Section titled âProblem 1: âTemplates are not exportable!ââCause: Attempting to export an unsigned template.
Solution: Sign the template first:
/certificate sign template-name/certificate export-certificate template-nameProblem 2: Certificate Has No Private Key (Missing K Flag)
Section titled âProblem 2: Certificate Has No Private Key (Missing K Flag)âCause: Key file not imported or key doesnât match certificate.
Solution:
# Import key separately/certificate import file-name=server.key
# Or use PKCS12 which bundles both/certificate import file-name=server.p12 passphrase=passwordProblem 3: Letâs Encrypt âHTTP Challenge Validation Failedâ
Section titled âProblem 3: Letâs Encrypt âHTTP Challenge Validation FailedââCauses:
- Port 80 not accessible from internet
- DNS not pointing to router
- www service disabled
Solution:
# Ensure www is enabled/ip service enable www
# Check firewall allows port 80/ip firewall filter print where dst-port=80
# Verify DNS resolves correctly (from external)# nslookup router.example.com should return your public IPProblem 4: Canât Sign - Imported CA Not Recognized
Section titled âProblem 4: Canât Sign - Imported CA Not RecognizedâCause: Imported CA lacks key-cert-sign permission.
Solution: Generate CA on RouterOS instead:
/certificate add name=newCA common-name="My CA" \ key-usage=key-cert-sign,crl-sign days-valid=3650/certificate sign newCAProblem 5: âUnable to Get Local Issuer Certificateâ on Fetch
Section titled âProblem 5: âUnable to Get Local Issuer Certificateâ on FetchâCause: Root CA not trusted (v7.19+).
Solution:
/certificate settings set builtin-trust-anchors=trustedProblem 6: Certificate Expired
Section titled âProblem 6: Certificate ExpiredâCheck expiration:
/certificate print detail where name=server-cert# Look at "expires-after" fieldFor Letâs Encrypt: Renewal happens automatically at 80% validity if port 80 is accessible.
For self-signed: Create new certificate and re-apply to services.
Problem 7: CA Removal Deleted All Certificates
Section titled âProblem 7: CA Removal Deleted All CertificatesâCause: Removing a CA removes all certificates it issued.
Prevention: Export certificates before removing CA:
/certificate export-certificate child-cert type=pkcs12 export-passphrase=backupVerification Commands
Section titled âVerification Commandsâ# List all certificates/certificate print
# Show certificate details/certificate print detail where name=router-cert
# Find certificates with private keys/certificate print where private-key=yes
# Find CA certificates/certificate print where ca=yes
# Find expired certificates/certificate print where expired=yes
# Check certificate assignment to services/ip service print where certificate!=""
# Verify settings/certificate settings print
# Test HTTPS fetch (requires trusted roots)/tool fetch url=https://example.com check-certificate=yesSecurity Best Practices
Section titled âSecurity Best Practicesâ- Use appropriate key sizes: 2048-bit RSA minimum, 4096-bit for long-lived CAs
- Set reasonable validity: 1-2 years for server certs, 5-10 years for CAs
- Include SANs: Modern browsers require Subject Alternative Names
- Protect private keys: Use strong export passphrases
- Enable CRL checking: For environments requiring revocation
- Keep system time accurate: Certificates depend on valid timestamps
- Back up CA certificates: CA loss means all issued certs become unverifiable
Related Features
Section titled âRelated Featuresâ- IP Services (
/ip service) - Apply certificates to www-ssl, api-ssl - OpenVPN (
/interface ovpn-server) - TLS-based VPN - SSTP (
/interface sstp-server) - SSL-based VPN - IPsec (
/ip ipsec) - Certificate-based IKEv2 - Dot1X (
/interface dot1x) - EAP-TLS authentication - Fetch (
/tool fetch) - HTTPS with certificate verification - DoH (
/ip dns) - DNS over HTTPS
Version Notes
Section titled âVersion Notesâ| Version | Feature |
|---|---|
| v7.19+ | Built-in root CA trust anchors |
| v7.7+ | Certificate import format changes |
| v7.1+ | Letâs Encrypt integration |
| v7.x | ACME support for alternative CAs |
Summary
Section titled âSummaryâCertificate management in RouterOS follows a straightforward workflow:
- Create template with properties (name, CN, key-usage, validity)
- Sign to create usable certificate (self-signed or with CA)
- Apply to services (www-ssl, VPN, etc.)
- Export/Import for distribution or backup
For public-facing services, Letâs Encrypt provides free automated certificates. For internal services, create your own CA and distribute it to clients. Always verify certificates have the K flag (private key) before applying to services.
Related Topics
Section titled âRelated TopicsâPrerequisites
Section titled âPrerequisitesâ- NTP Client - accurate time required for certificate validation
Services Using Certificates
Section titled âServices Using Certificatesâ- IP Services (SSH) - enable secure management access
- OpenVPN - TLS-based VPN
- IPsec IKEv2 - certificate-based VPN authentication
- SSTP VPN - SSL-based VPN
- Dot1X - EAP-TLS authentication
Related Security
Section titled âRelated Securityâ- User Management - manage admin access
- Firewall Basics - protect management interfaces
Related Topics
Section titled âRelated Topicsâ- IP Cloud - DDNS for Letâs Encrypt certificates
- DNS Server - DNS resolution for ACME validation