修改证书配置
This commit is contained in:
parent
b61d43fe8e
commit
ae8a61ace8
@ -8,12 +8,16 @@
|
|||||||
{backlog, 10240}
|
{backlog, 10240}
|
||||||
]},
|
]},
|
||||||
|
|
||||||
|
%% 证书配置
|
||||||
|
{certificate, [
|
||||||
|
{certfile, "/usr/local/code/erl/sdlan/priv/ssl/server.crt"},
|
||||||
|
{keyfile, "/usr/local/code/erl/sdlan/priv/ssl/server.key"}
|
||||||
|
]},
|
||||||
|
|
||||||
{quic_server, [
|
{quic_server, [
|
||||||
{port, 443},
|
{port, 443},
|
||||||
{acceptors, 10},
|
{acceptors, 10},
|
||||||
{alpn, ["punchnet/1.0"]},
|
{alpn, ["punchnet/1.0"]},
|
||||||
{certfile, "cert.pem"},
|
|
||||||
{keyfile, "key.pem"},
|
|
||||||
{limits, [
|
{limits, [
|
||||||
{max_packet_size, 16384},
|
{max_packet_size, 16384},
|
||||||
{stream_active_n, 100},
|
{stream_active_n, 100},
|
||||||
@ -27,8 +31,6 @@
|
|||||||
{acceptors, 500},
|
{acceptors, 500},
|
||||||
{max_connections, 10240},
|
{max_connections, 10240},
|
||||||
{backlog, 10240},
|
{backlog, 10240},
|
||||||
{certfile, "server.crt"},
|
|
||||||
{keyfile, "server.key"},
|
|
||||||
{limits, [
|
{limits, [
|
||||||
{max_packet_size, 16384},
|
{max_packet_size, 16384},
|
||||||
%% 单位为秒
|
%% 单位为秒
|
||||||
|
|||||||
@ -8,12 +8,16 @@
|
|||||||
{backlog, 10240}
|
{backlog, 10240}
|
||||||
]},
|
]},
|
||||||
|
|
||||||
|
%% 证书配置
|
||||||
|
{certificate, [
|
||||||
|
{certfile, "fullchain.cer"},
|
||||||
|
{keyfile, "root.punchsky.com.key"}
|
||||||
|
]},
|
||||||
|
|
||||||
{quic_server, [
|
{quic_server, [
|
||||||
{port, 443},
|
{port, 443},
|
||||||
{acceptors, 10},
|
{acceptors, 10},
|
||||||
{alpn, ["punchnet/1.0"]},
|
{alpn, ["punchnet/1.0"]},
|
||||||
{certfile, "fullchain.cer"},
|
|
||||||
{keyfile, "root.punchsky.com.key"},
|
|
||||||
{limits, [
|
{limits, [
|
||||||
{max_packet_size, 16384},
|
{max_packet_size, 16384},
|
||||||
{stream_active_n, 100},
|
{stream_active_n, 100},
|
||||||
@ -27,8 +31,6 @@
|
|||||||
{acceptors, 500},
|
{acceptors, 500},
|
||||||
{max_connections, 10240},
|
{max_connections, 10240},
|
||||||
{backlog, 10240},
|
{backlog, 10240},
|
||||||
{certfile, "server.crt"},
|
|
||||||
{keyfile, "server.key"},
|
|
||||||
{limits, [
|
{limits, [
|
||||||
{max_packet_size, 16384},
|
{max_packet_size, 16384},
|
||||||
%% 单位为秒
|
%% 单位为秒
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIDazCCAlOgAwIBAgIUEhYvMYhAARHRpKd1EOTR7HiRIVkwDQYJKoZIhvcNAQEL
|
|
||||||
BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
|
|
||||||
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yNjAyMTEwOTMyMjlaFw0yNzAy
|
|
||||||
MTEwOTMyMjlaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw
|
|
||||||
HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB
|
|
||||||
AQUAA4IBDwAwggEKAoIBAQDWKHFkwDMH/XjY3joBwT3zzgh5WkqG7dKuj7YV7WdX
|
|
||||||
JjOc46iqNsvyieHTfuJBuPirLDAX2hGzU0OheeQBg/a9pFQxxyRBN2UZUFwTHPTG
|
|
||||||
TBBvdQGcC2vMQ3HnJwUoPzJRCYPBXQZ3JSmlq+y1uJzpLQfYeiRtowfGrRrd0jHJ
|
|
||||||
Xt5amitoN7m9VshG7KCg2K8AVriP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
|
||||||
7ZQ5WhXgBwOISVz0X1Z+NLH0uu20Zw3WofLVy3tD7UVC219Kjv7+hEA8tO6sC5lK
|
|
||||||
Csk93HpdmjjoxujP1Owh5TCgsnGX4e5Z5LYAyp0vFB/EyeJfhJnCe6SnAoGAfU5O
|
|
||||||
zSQUAVpDZt23XdP5/Ml02ZEZLD3F3u0wWMzlWL2zfZ+6EH0/CEMBND6/ruaMT12f
|
|
||||||
tRNaN6sFwEYTtG64SNfdUW4y0HNzJeZCETj9fKPOQe5ulvxIiINkhICBTmJX2S6s
|
|
||||||
i76o1UvEW5xxe+bcu0pEbl/M1P0l5fd6LgHovfUCgYADQHISMiW1JqCnM/Mu0WhD
|
|
||||||
i++BWMnUCb9BqFk/IPnKJUZUPLNKQ3izuvrNKpvd5HwSm7278h6SX2LaU+1D+Pcw
|
|
||||||
vvQGMhK7FDhO0E7qOu/pNDRtaNnKIeG76GoYAkGdm2dc3kY8mxlLIgegL/ateuf0
|
|
||||||
AXBDlbmJJZgDYNioytFKnw==
|
|
||||||
-----END PRIVATE KEY-----
|
|
||||||
@ -23,17 +23,15 @@ init() ->
|
|||||||
Port = proplists:get_value(port, Props),
|
Port = proplists:get_value(port, Props),
|
||||||
Alpn = proplists:get_value(alpn, Props),
|
Alpn = proplists:get_value(alpn, Props),
|
||||||
Limits = proplists:get_value(limits, Props),
|
Limits = proplists:get_value(limits, Props),
|
||||||
CertFile = proplists:get_value(certfile, Props),
|
|
||||||
KeyFile = proplists:get_value(keyfile, Props),
|
|
||||||
AcceptorCount = proplists:get_value(acceptors, Props, 10),
|
AcceptorCount = proplists:get_value(acceptors, Props, 10),
|
||||||
|
|
||||||
%% 获取环境变量
|
%% 证书配置
|
||||||
Path = os:getenv("QUIC_CERT_PATH"),
|
{CertFile, KeyFile} = sdlan_util:certificate_config(),
|
||||||
|
|
||||||
LOptions = #{
|
LOptions = #{
|
||||||
% 必选:QUIC/TLS证书配置
|
% 必选:QUIC/TLS证书配置
|
||||||
certfile => Path ++ "/" ++ CertFile,
|
certfile => CertFile,
|
||||||
keyfile => Path ++ "/" ++ KeyFile,
|
keyfile => KeyFile,
|
||||||
alpn => Alpn,
|
alpn => Alpn,
|
||||||
peer_bidi_stream_count => 1,
|
peer_bidi_stream_count => 1,
|
||||||
conn_acceptors => AcceptorCount
|
conn_acceptors => AcceptorCount
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
-export([ipv4_to_int/1, int_to_ipv4/1, ips/2, format_ip/1]).
|
-export([ipv4_to_int/1, int_to_ipv4/1, ips/2, format_ip/1]).
|
||||||
-export([ipv6_to_bytes/1, ipv6_bytes_to_binary/1, ipv6_assist_info/0]).
|
-export([ipv6_to_bytes/1, ipv6_bytes_to_binary/1, ipv6_assist_info/0]).
|
||||||
-export([hmac/2, term_to_binary/1]).
|
-export([hmac/2, term_to_binary/1]).
|
||||||
|
-export([certificate_config/0]).
|
||||||
|
|
||||||
-spec format_mac(Mac :: binary()) -> binary().
|
-spec format_mac(Mac :: binary()) -> binary().
|
||||||
format_mac(Mac) when is_binary(Mac) ->
|
format_mac(Mac) when is_binary(Mac) ->
|
||||||
@ -166,3 +167,13 @@ hmac(Key, Data) when is_binary(Key), is_binary(Data) ->
|
|||||||
-spec term_to_binary(Term :: term()) -> binary().
|
-spec term_to_binary(Term :: term()) -> binary().
|
||||||
term_to_binary(Term) ->
|
term_to_binary(Term) ->
|
||||||
iolist_to_binary(io_lib:format("~p", [Term])).
|
iolist_to_binary(io_lib:format("~p", [Term])).
|
||||||
|
|
||||||
|
-spec certificate_config() -> {CertFile :: string(), KeyFile :: string()}.
|
||||||
|
certificate_config() ->
|
||||||
|
{ok, Props} = application:get_env(sdlan, certificate),
|
||||||
|
CertFile = proplists:get_value(certfile, Props),
|
||||||
|
KeyFile = proplists:get_value(keyfile, Props),
|
||||||
|
%% 获取环境变量
|
||||||
|
Path = os:getenv("QUIC_CERT_PATH"),
|
||||||
|
% 必选:QUIC/TLS证书配置
|
||||||
|
{Path ++ "/" ++ CertFile, Path ++ "/" ++ KeyFile}.
|
||||||
@ -22,14 +22,13 @@ start() ->
|
|||||||
Port = proplists:get_value(port, Props),
|
Port = proplists:get_value(port, Props),
|
||||||
Limits = proplists:get_value(limits, Props, []),
|
Limits = proplists:get_value(limits, Props, []),
|
||||||
|
|
||||||
PrivDir = code:priv_dir(sdlan),
|
%% 证书配置
|
||||||
CertFile = filename:join([PrivDir, "ssl", proplists:get_value(certfile, Props, "server.crt")]),
|
{CertFile, KeyFile} = sdlan_util:certificate_config(),
|
||||||
KeyFile = filename:join([PrivDir, "ssl", proplists:get_value(keyfile, Props, "server.key")]),
|
|
||||||
|
|
||||||
TransOpts = #{
|
TransOpts = #{
|
||||||
max_connections => MaxConnections,
|
max_connections => MaxConnections,
|
||||||
num_acceptors => Acceptors,
|
num_acceptors => Acceptors,
|
||||||
shutdown => brutal_kill,
|
shutdown => 2000,
|
||||||
socket_opts => [
|
socket_opts => [
|
||||||
binary,
|
binary,
|
||||||
{nodelay, true},
|
{nodelay, true},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user