Cryptography · Topic 4 of 4

Certificates in RouterOS

Create a self signed CA and server certificate on RouterOS, import a free valid certificate, and assign certificates to HTTPS, SSTP and other services.

  • 5 min
In a nutshell
  • A private CA on the router signs server certificates for free.
  • Create with /certificate add, then sign with /certificate sign.
  • common-name, subject-alt-name and key-usage describe the owner, the names and the allowed uses.

What it is

A certificate on a router gives a service a verified identity and lets the service encrypt its connections.

There are two ways to get one. You can make your own with a private CA, which is free and fast but trusted only where you install it. Or you can obtain a free certificate from a public authority that every client already trusts.

Whichever way you choose, the last step is the same. You assign the certificate to the service that needs it.

CA certificateself signedsignsServer certificaterouter nameassigned toServiceHTTPS or SSTPtrusted byClienthas the CA installed

How it works

You create keys and certificates in the certificate menu, sign them, and then select them in the service settings.

Self signed certificates

The usual method is to make a small private CA on the router and sign a server certificate with it. First create and sign the CA certificate.

/certificate add name=local-ca common-name=local-ca key-usage=key-cert-sign,crl-sign days-valid=3650
/certificate sign local-ca

Then create the server certificate for the router name and sign it with the CA.

/certificate add name=router-cert common-name=router.example.com subject-alt-name=DNS:router.example.com key-usage=digital-signature,key-encipherment,tls-server days-valid=365
/certificate sign router-cert ca=local-ca

The validity periods are example values.

The common-name is the name of the owner. The subject-alt-name lists the names that clients may use, and modern clients check it. The key-usage lists what the certificate may be used for.

You can also use a single self signed certificate with no CA. It works for tests, but every client must trust that exact certificate.

Trusting a private CA

A client trusts the server certificate only if it trusts the CA that signed it. Export the CA certificate and install it on each client.

/certificate export-certificate local-ca file-name=local-ca

The export writes a certificate file that you copy to the client and add to its trust store. Do not export the private key of the CA unless you have a reason and protect the file.

Free valid certificates

A public authority such as Let's Encrypt issues certificates for free. Browsers and operating systems already trust these authorities, so clients need no extra installation.

The authority checks that you control the name, usually through a public web server or a DNS record. Because the router name must be reachable for this check, many people request the certificate on another machine and bring it to the router.

/certificate import file-name=fullchain.pem passphrase=""
/certificate import file-name=privkey.pem passphrase=""

The first command imports the certificate file. The second imports the private key.

If the authority gives you the chain as separate files, import those too. Free certificates are valid for a short time, so you must renew and import again before they expire.

Some RouterOS releases include a built in way to request a certificate from Let's Encrypt, so check what your version offers.

Using certificates in RouterOS

Once a certificate is on the router, you select it in the service. Each service has its own certificate setting.

ServiceWhere you select the certificate
HTTPS web interface/ip service set www-ssl certificate=
Secure API/ip service set api-ssl certificate=
SSTP server/interface sstp-server server set certificate=
IPsec with certificatesThe peer and identity settings
/ip service set www-ssl certificate=router-cert disabled=no
/ip service set api-ssl certificate=router-cert disabled=no

After you assign the certificate, a browser that trusts the CA opens the web interface without a warning.

Checking the result

/certificate print
/ip service print

Look for the K flag, which shows that the router holds the private key. The service listing shows which certificate each service uses. If a client still warns, check the name, the dates and whether the client trusts the CA.

Exam tip

Use a long validity for the CA and a shorter one for the server certificates. You can then renew the server certificates without touching the clients.

What to remember for the exam

Seven facts cover certificates on RouterOS.

  • A private CA on the router signs server certificates for free.
  • Create with /certificate add, then sign with /certificate sign.
  • common-name, subject-alt-name and key-usage describe the owner, the names and the allowed uses.
  • Clients must install the CA certificate to trust a private CA.
  • Public authorities such as Let's Encrypt give free certificates that clients already trust, but they expire soon.
  • Import certificate files with /certificate import.
  • Select the certificate in the service, for example /ip service set www-ssl certificate=.

Common mistakes

Four mistakes appear in this area.

Forgetting to sign the certificate. A certificate that is only added has no issuer and no valid signature.

Not installing the CA on the client. The browser keeps warning, although the setup is correct.

Using a name that does not match. The client connects to an address that is not in the certificate, so the check fails.

Letting a free certificate expire. The service still runs, but clients refuse it until you import a fresh certificate.

Watch out

Protect the private key and any backup that contains it. Anyone with the key can pose as your router.

Check yourself

Work through these three questions.

  • What are the two steps to make a server certificate with a private CA on RouterOS?

    First create it with /certificate add, then sign it with /certificate sign and the ca parameter. The CA must itself be created and signed first.

  • Why does a browser warn about a certificate that was signed by your own CA?

    The browser does not have your CA in its trust store. Install the CA certificate on the client to remove the warning.

  • How do you make the HTTPS web interface use a certificate?

    Run /ip service set www-ssl certificate=router-cert disabled=no with the name of your certificate.

Topic 4 of 4 in Cryptography

Test yourself on Cryptography

The full MikroTik MTCSE question bank has 446 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by MikroTik. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.