中文 | English
File Lite (Go backend) turns on HTTPS through the sslKey and sslCert fields of config.json in the data directory. When both are non-empty the server starts with HTTPS; otherwise it starts with HTTP. Paths are relative to the data directory (default <cwd>/file-lite/, overridable with --data-dir or FILE_LITE_DATA_BASE_DIR).
Option 1: generate it when the config is first created. The Go standard library does this; OpenSSL or any other external command is not required.
./file-lite-go --create-config --with-tlsThis writes key.pem (private key) and cert.pem (certificate) into the data directory and sets sslKey / sslCert in config.json. The certificate:
- Has subject
CN=file-lite, an RSA 2048-bit key, and a validity of 365 days.CNis only the certificate's name and is not used for hostname checks. - Always includes
DNS:localhost,IP:127.0.0.1andIP:::1insubjectAltName(SAN). When--tls-hostis not set, the detected addresses of the local interfaces are added as well (link-local addresses are skipped). Current browsers and Go check the hostname against the SAN only.
To add other names or addresses, repeat --tls-host:
./file-lite-go --create-config --with-tls \
--tls-host app.local --tls-host 192.168.1.10--tls-host <host>appends a DNS name or an IP to the SAN. It may be repeated. IPv6 may be written as[::1]or::1.- Once
--tls-hostis set, local IPs are no longer scanned. The SAN is onlylocalhost, the loopback addresses, and the hosts you named, so addresses from virtual interfaces (docker0, veth, and so on) stay out. Write a local IP explicitly if you want it included.
Generating or reusing a certificate prints the full certificate details:
tls cert written: key.pem, cert.pem
subject: CN=file-lite
pubkey: RSA 2048-bit
sig: SHA256-RSA
serial: 219414278114519540679476560263082189088
validity: 2026-09-10 ~ 2027-09-10 (365 days left)
sha256: FB:0F:8B:AC:A5:1E:EB:90:56:B2:E2:A0:75:CA:52:55:D7:F5:7C:19:6F:D8:4E:7A:78:CF:D4:20:BB:70:FE:D5
san: localhost, app.local, 127.0.0.1, ::1, 192.168.1.10
source: defaults + --tls-host (local IP scan skipped)
cert: /path/to/file-lite/cert.pem
key: /path/to/file-lite/key.pem
If both key.pem and cert.pem already exist, generation is skipped and the existing files are reused (the printout is then the existing certificate). If a --tls-host you passed is not covered by that certificate, an extra warning: line is printed; delete the two files as it says and generate them again.
Option 2: generate it yourself with OpenSSL
# Change to the data directory
cd file-lite
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pemOn Windows, run the command above in Git Bash. Git for Windows has to be installed first.
The command writes two files:
- key.pem: the private key
- cert.pem: the certificate
OpenSSL then asks for a country code, state, city, organization, organizational unit, common name (domain) and email address. Fill those in as you like. Common Name (e.g. server FQDN or YOUR name) []: matters: usually the server's domain name, or localhost for local development.
Edit file-lite/config.json and set sslKey and sslCert (paths relative to the data directory):
{
"sslKey": "key.pem",
"sslCert": "cert.pem"
}After a restart the console prints HTTPS enabled and the links use https://.
How you trust it depends on the operating system and the browser.
Windows:
- Double-click
cert.pem. - Choose "Install Certificate".
- Choose "Local Machine" and click "Next".
- Choose "Place all certificates in the following store" and click "Browse".
- Choose "Trusted Root Certification Authorities" and click "OK".
- Click "Next" and "Finish".
- If a security warning appears, click "Yes".
macOS:
- Double-click
cert.pem. - Keychain Access opens.
- In the Keychain menu, choose "System".
- Click "Add".
- Find the certificate you added (it is usually shown as your Common Name).
- Double-click the certificate.
- Under Trust, set "When using this certificate" to "Always Trust".
- Enter your administrator password.
Linux (Ubuntu):
-
Copy
cert.peminto/usr/local/share/ca-certificates/:sudo cp cert.pem /usr/local/share/ca-certificates/my-app.crt
-
Update the trust store:
sudo update-ca-certificates
Restart the browser. https://localhost:<port> should no longer show a security warning.
- A self-signed certificate is not trusted. The browser warns until you trust it by hand.
- Development only. A self-signed certificate is not appropriate for production. Production should use a certificate from a trusted CA.
- Validity. The generated certificate lasts 365 days. An OpenSSL certificate lasts however many days
-dayssets (365 above). Either can be changed. When it expires, regeneratekey.pemandcert.pemand restart. - Keep the private key (
key.pem) private. Do not give it to anyone.