Skip to content

Commit e1c6fdb

Browse files
committed
cert.go
1 parent 217f65c commit e1c6fdb

22 files changed

Lines changed: 788 additions & 8 deletions

common/protocol/tls/cert/cert.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ func GenerateGOST2012_256(parent *Certificate, opts ...SM2Option) (*Certificate,
185185
var (
186186
commonName string
187187
organization string
188-
dnsNames []string
189188
expireDays int = 365
190189
)
191190

@@ -200,9 +199,6 @@ func GenerateGOST2012_256(parent *Certificate, opts ...SM2Option) (*Certificate,
200199
if len(tmp.Subject.Organization) > 0 {
201200
organization = tmp.Subject.Organization[0]
202201
}
203-
if len(tmp.DNSNames) > 0 {
204-
dnsNames = tmp.DNSNames
205-
}
206202
if !tmp.NotAfter.IsZero() {
207203
days := int(tmp.NotAfter.Sub(time.Now()).Hours() / 24)
208204
if days > 0 {
@@ -236,7 +232,6 @@ func GenerateGOST2012_512(parent *Certificate, opts ...SM2Option) (*Certificate,
236232
var (
237233
commonName string
238234
organization string
239-
dnsNames []string
240235
expireDays int = 365
241236
)
242237

@@ -251,9 +246,6 @@ func GenerateGOST2012_512(parent *Certificate, opts ...SM2Option) (*Certificate,
251246
if len(tmp.Subject.Organization) > 0 {
252247
organization = tmp.Subject.Organization[0]
253248
}
254-
if len(tmp.DNSNames) > 0 {
255-
dnsNames = tmp.DNSNames
256-
}
257249
if !tmp.NotAfter.IsZero() {
258250
days := int(tmp.NotAfter.Sub(time.Now()).Hours() / 24)
259251
if days > 0 {

samples/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Примеры (samples)
2+
3+
## Структура
4+
- `make_cert/` — скрипты генерации тестовых сертификатов (SM2, GOST, ECDSA)
5+
- `certs/` — сгенерированные сертификаты
6+
- `configs/server/` — серверные конфиги VMess/VLESS
7+
- `configs/client/` — клиентские конфиги
8+
- `run/server/` — запуск сервера с нужным конфигом
9+
- `run/client/` — запуск клиента
10+
- `scripts/` — проверка сертификатов
11+
12+
## Использование
13+
```bash
14+
# Генерация всех сертификатов
15+
cd make_cert && ./make_all_certs.sh
16+
17+
# Проверка всех сертификатов
18+
cd scripts && ./verify_all_certs.sh
19+
20+
# Запуск сервера
21+
cd run/server && ./run_vmess_sm2.sh
22+
23+
# Запуск клиента
24+
cd run/client && ./run_vless_client_sm2.sh
25+
```
26+
27+
Конфиги пересоздавать не нужно, используйте как есть.
28+
Скрипты генерации сертификатов — только для теста.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"log": {
3+
"loglevel": "info"
4+
},
5+
"inbounds": [
6+
{
7+
"port": 1080,
8+
"protocol": "socks",
9+
"settings": {
10+
"auth": "noauth",
11+
"udp": true
12+
}
13+
}
14+
],
15+
"outbounds": [
16+
{
17+
"protocol": "vless",
18+
"settings": {
19+
"vnext": [
20+
{
21+
"address": "127.0.0.1",
22+
"port": 443,
23+
"users": [
24+
{
25+
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
26+
"encryption": "none"
27+
}
28+
]
29+
}
30+
]
31+
},
32+
"streamSettings": {
33+
"network": "tcp",
34+
"security": "tls",
35+
"tlsSettings": {
36+
"allowInsecure": true,
37+
"serverName": "example.com"
38+
}
39+
}
40+
}
41+
]
42+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"log": {
3+
"loglevel": "debug"
4+
},
5+
"inbounds": [
6+
{
7+
"port": 443,
8+
"protocol": "vless",
9+
"settings": {
10+
"clients": [
11+
{
12+
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
13+
}
14+
],
15+
"decryption": "none"
16+
},
17+
"streamSettings": {
18+
"network": "tcp",
19+
"security": "tls",
20+
"tlsSettings": {
21+
"certificates": [
22+
{
23+
"certificateFile": "../certs/test_cert_sm2.crt",
24+
"keyFile": "../certs/test_cert_sm2.key",
25+
"certificateType": "sm2"
26+
}
27+
]
28+
}
29+
}
30+
}
31+
],
32+
"outbounds": [
33+
{
34+
"protocol": "freedom"
35+
}
36+
]
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"log": {
3+
"loglevel": "debug"
4+
},
5+
"inbounds": [
6+
{
7+
"port": 443,
8+
"protocol": "vmess",
9+
"settings": {
10+
"clients": [
11+
{
12+
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
13+
"alterId": 0
14+
}
15+
]
16+
},
17+
"streamSettings": {
18+
"network": "tcp",
19+
"security": "tls",
20+
"tlsSettings": {
21+
"certificates": [
22+
{
23+
"certificateFile": "../certs/test_cert_gost2012_512.crt",
24+
"keyFile": "../certs/test_cert_gost2012_512.key",
25+
"certificateType": "gost2012_512"
26+
}
27+
]
28+
}
29+
}
30+
}
31+
],
32+
"outbounds": [
33+
{
34+
"protocol": "freedom"
35+
}
36+
]
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"log": {
3+
"loglevel": "info"
4+
},
5+
"inbounds": [
6+
{
7+
"port": 443,
8+
"protocol": "vmess",
9+
"settings": {
10+
"clients": [
11+
{
12+
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
13+
"alterId": 0
14+
}
15+
]
16+
},
17+
"streamSettings": {
18+
"network": "tcp",
19+
"security": "tls",
20+
"tlsSettings": {
21+
"certificates": [
22+
{
23+
"certificateFile": "../certs/test_cert_sm2.crt",
24+
"keyFile": "../certs/test_cert_sm2.key",
25+
"certificateType": "sm2"
26+
}
27+
]
28+
}
29+
}
30+
}
31+
],
32+
"outbounds": [
33+
{
34+
"protocol": "freedom"
35+
}
36+
]
37+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
cd "$(dirname "$0")"
5+
6+
./make_cert_sm2.sh
7+
./make_cert_gost2012_256.sh
8+
./make_cert_gost2012_512.sh
9+
./make_cert_ecdsa.sh
10+
11+
echo "\nВсе сертификаты сгенерированы в папку ../certs/"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Generate ECDSA certificate
4+
../../xray tls cert --algorithm=ecdsa --domain=example.com --name="Test Server ECDSA" --org="Test Organization" --file=../certs/test_cert_ecdsa
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Generate GOST2012_256 certificate
4+
../../xray tls cert --algorithm=gost2012_256 --domain=example.com --name="Test Server GOST2012_256" --org="Test Organization" --file=../certs/test_cert_gost2012_256
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
# Generate GOST2012_512 certificate
4+
../../xray tls cert --algorithm=gost2012_512 --domain=example.com --name="Test Server GOST2012_512" --org="Test Organization" --file=../certs/test_cert_gost2012_512
5+
6+
7+

0 commit comments

Comments
 (0)