2026-06-26 15:56:15 +03:00
|
|
|
# Generating SSL Certificate for Nginx in XC_VM
|
2026-03-15 00:02:19 +03:00
|
|
|
|
2026-04-17 19:56:58 +03:00
|
|
|
This guide explains how to create a self-signed SSL certificate to enable secure HTTPS connections for the built-in Nginx server in the XC_VM project.
|
2026-03-15 00:02:19 +03:00
|
|
|
|
2026-06-26 15:56:15 +03:00
|
|
|
> **Note:** A fresh install already generates a **unique** self-signed certificate
|
|
|
|
|
> automatically (the installer runs `openssl` and writes `server.key`/`server.crt`
|
|
|
|
|
> into `bin/nginx/conf/` before Nginx starts), and `CertbotCronJob` later replaces
|
|
|
|
|
> it with a real Let's Encrypt certificate. Follow this guide only to **regenerate
|
|
|
|
|
> or replace** the certificate manually.
|
2026-03-15 00:02:19 +03:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2026-06-26 15:56:15 +03:00
|
|
|
## Overview
|
2026-03-15 00:02:19 +03:00
|
|
|
|
|
|
|
|
**SSL (Secure Sockets Layer)** encrypts the connection between client and server, ensuring data confidentiality and user trust.
|
|
|
|
|
This tutorial shows how to create a **self-signed SSL certificate** for the embedded **Nginx** server in the **XC_VM** project.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Configuration Location
|
|
|
|
|
|
|
|
|
|
All SSL-related files (key, certificate, and config) are stored in:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
/home/xc_vm/bin/nginx/conf
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Navigate to this directory before proceeding:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cd /home/xc_vm/bin/nginx/conf
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Step 1. Generate Private Key
|
|
|
|
|
|
|
|
|
|
Generate a **2048-bit RSA private key**:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
openssl genrsa -out server.key 2048
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
After execution, the file `server.key` will appear — this is your **private key**.
|
|
|
|
|
Keep it **strictly confidential** — it is used to sign the SSL certificate.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Step 2. Create server.cnf Configuration File
|
|
|
|
|
|
|
|
|
|
Create a configuration file containing certificate parameters:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cat > server.cnf << EOF
|
|
|
|
|
[req]
|
|
|
|
|
distinguished_name = req_distinguished_name
|
|
|
|
|
x509_extensions = v3_req
|
|
|
|
|
prompt = no
|
|
|
|
|
|
|
|
|
|
[req_distinguished_name]
|
|
|
|
|
C = RU
|
|
|
|
|
ST = Moscow
|
|
|
|
|
L = Moscow
|
|
|
|
|
O = XC_VM
|
|
|
|
|
OU = XC_VM
|
|
|
|
|
CN = XC_VM
|
|
|
|
|
|
|
|
|
|
[v3_req]
|
|
|
|
|
keyUsage = keyEncipherment, dataEncipherment
|
|
|
|
|
extendedKeyUsage = serverAuth
|
|
|
|
|
subjectAltName = @alt_names
|
|
|
|
|
|
|
|
|
|
[alt_names]
|
|
|
|
|
DNS.1 = XC_VM
|
|
|
|
|
EOF
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Parameter explanation:**
|
|
|
|
|
|
2026-04-17 19:56:58 +03:00
|
|
|
| Field | Value | Purpose |
|
|
|
|
|
| --- | --- | --- |
|
|
|
|
|
| `C` | RU | Country |
|
|
|
|
|
| `ST` | Moscow | State/Province |
|
|
|
|
|
| `L` | Moscow | City/Locality |
|
|
|
|
|
| `O` | XC_VM | Organization |
|
|
|
|
|
| `OU` | XC_VM | Organizational Unit |
|
|
|
|
|
| `CN` | XC_VM | Common Name (primary hostname) |
|
|
|
|
|
| `DNS.1` | XC_VM | Subject Alternative Name (SAN) |
|
2026-03-15 00:02:19 +03:00
|
|
|
|
|
|
|
|
> **Tip:** For real domain names, replace `DNS.1 = XC_VM` with your actual domain (e.g., `DNS.1 = panel.example.com`) to avoid browser warnings.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Step 3. Generate Self-Signed SSL Certificate
|
|
|
|
|
|
|
|
|
|
Generate the certificate using the private key and configuration file:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
openssl req -new -x509 -key server.key -out server.crt -days 3650 -config server.cnf
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Explanation:**
|
|
|
|
|
|
2026-04-17 19:56:58 +03:00
|
|
|
- `-new -x509` — creates a new self-signed certificate
|
|
|
|
|
- `-days 3650` — certificate validity period (10 years)
|
|
|
|
|
- `-config server.cnf` — uses the custom configuration
|
|
|
|
|
- Result: `server.crt` file containing the public certificate
|
2026-03-15 00:02:19 +03:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Final Files
|
|
|
|
|
|
|
|
|
|
After completing all steps, the following files should be present in `/home/xc_vm/bin/nginx/conf`:
|
|
|
|
|
|
2026-04-17 19:56:58 +03:00
|
|
|
| File | Purpose |
|
|
|
|
|
| --- | --- |
|
|
|
|
|
| `server.key` | Private key |
|
|
|
|
|
| `server.crt` | Self-signed SSL certificate |
|
|
|
|
|
| `server.cnf` | Certificate configuration file |
|
2026-03-15 00:02:19 +03:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Result
|
|
|
|
|
|
|
|
|
|
Your **XC_VM Nginx server** is now accessible via **HTTPS** using the newly created self-signed certificate.
|
|
|
|
|
Browsers will display a “not trusted” warning — this is expected behavior for self-signed certificates.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Notes
|
|
|
|
|
|
2026-04-17 19:56:58 +03:00
|
|
|
- Self-signed certificates are suitable **for internal use or testing only**.
|
|
|
|
|
- For public-facing domains, use certificates from trusted CAs (e.g., [Let's Encrypt](https://letsencrypt.org/)).
|
2026-06-26 15:56:15 +03:00
|
|
|
- If you change the Domain/hostname (`CN` or `DNS.1`), you **must regenerate** the certificate.
|
2026-04-17 19:56:58 +03:00
|
|
|
- To inspect the generated certificate:
|
2026-03-15 00:02:19 +03:00
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
openssl x509 -in server.crt -text -noout
|
|
|
|
|
```
|
|
|
|
|
|
2026-04-17 19:56:58 +03:00
|
|
|
---
|