mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-09-15 21:00:27 +00:00
Add ACME profile support for IP address certificates
This commit is contained in:
@@ -69,10 +69,21 @@ func startACME(ctx context.Context, logger logger.Logger, options option.Inbound
|
|||||||
Storage: storage,
|
Storage: storage,
|
||||||
Logger: zapLogger,
|
Logger: zapLogger,
|
||||||
}
|
}
|
||||||
|
profile := options.Profile
|
||||||
|
if profile == "" && acmeServer == certmagic.LetsEncryptProductionCA {
|
||||||
|
for _, domain := range options.Domain {
|
||||||
|
if certmagic.SubjectIsIP(domain) {
|
||||||
|
profile = "shortlived"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
acmeConfig := certmagic.ACMEIssuer{
|
acmeConfig := certmagic.ACMEIssuer{
|
||||||
CA: acmeServer,
|
CA: acmeServer,
|
||||||
Email: options.Email,
|
Email: options.Email,
|
||||||
Agreed: true,
|
Agreed: true,
|
||||||
|
Profile: profile,
|
||||||
DisableHTTPChallenge: options.DisableHTTPChallenge,
|
DisableHTTPChallenge: options.DisableHTTPChallenge,
|
||||||
DisableTLSALPNChallenge: options.DisableTLSALPNChallenge,
|
DisableTLSALPNChallenge: options.DisableTLSALPNChallenge,
|
||||||
AltHTTPPort: int(options.AlternativeHTTPPort),
|
AltHTTPPort: int(options.AlternativeHTTPPort),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ icon: material/new-box
|
|||||||
|
|
||||||
:material-plus: [account_key](#account_key)
|
:material-plus: [account_key](#account_key)
|
||||||
:material-plus: [key_type](#key_type)
|
:material-plus: [key_type](#key_type)
|
||||||
|
:material-plus: [profile](#profile)
|
||||||
:material-plus: [http_client](#http_client)
|
:material-plus: [http_client](#http_client)
|
||||||
|
|
||||||
# ACME
|
# ACME
|
||||||
@@ -37,6 +38,7 @@ icon: material/new-box
|
|||||||
},
|
},
|
||||||
"dns01_challenge": {},
|
"dns01_challenge": {},
|
||||||
"key_type": "",
|
"key_type": "",
|
||||||
|
"profile": "",
|
||||||
"http_client": "" // or {}
|
"http_client": "" // or {}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -141,6 +143,14 @@ The private key type to generate for new certificates.
|
|||||||
| `rsa2048` | RSA |
|
| `rsa2048` | RSA |
|
||||||
| `rsa4096` | RSA |
|
| `rsa4096` | RSA |
|
||||||
|
|
||||||
|
#### profile
|
||||||
|
|
||||||
|
!!! question "Since sing-box 1.14.0"
|
||||||
|
|
||||||
|
The ACME profile to use for certificate issuance.
|
||||||
|
|
||||||
|
When empty and `provider` is Let's Encrypt, `shortlived` will be used automatically if any domain is an IP address.
|
||||||
|
|
||||||
#### http_client
|
#### http_client
|
||||||
|
|
||||||
!!! question "Since sing-box 1.14.0"
|
!!! question "Since sing-box 1.14.0"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ icon: material/new-box
|
|||||||
|
|
||||||
:material-plus: [account_key](#account_key)
|
:material-plus: [account_key](#account_key)
|
||||||
:material-plus: [key_type](#key_type)
|
:material-plus: [key_type](#key_type)
|
||||||
|
:material-plus: [profile](#profile)
|
||||||
:material-plus: [http_client](#http_client)
|
:material-plus: [http_client](#http_client)
|
||||||
|
|
||||||
# ACME
|
# ACME
|
||||||
@@ -37,6 +38,7 @@ icon: material/new-box
|
|||||||
},
|
},
|
||||||
"dns01_challenge": {},
|
"dns01_challenge": {},
|
||||||
"key_type": "",
|
"key_type": "",
|
||||||
|
"profile": "",
|
||||||
"http_client": "" // 或 {}
|
"http_client": "" // 或 {}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -136,6 +138,14 @@ ACME DNS01 质询字段。如果配置,将禁用其他质询方法。
|
|||||||
| `rsa2048` | RSA |
|
| `rsa2048` | RSA |
|
||||||
| `rsa4096` | RSA |
|
| `rsa4096` | RSA |
|
||||||
|
|
||||||
|
#### profile
|
||||||
|
|
||||||
|
!!! question "自 sing-box 1.14.0 起"
|
||||||
|
|
||||||
|
用于证书签发的 ACME profile。
|
||||||
|
|
||||||
|
当为空且 `provider` 为 Let's Encrypt 时,如果任意域名为 IP 地址,将自动使用 `shortlived`。
|
||||||
|
|
||||||
#### http_client
|
#### http_client
|
||||||
|
|
||||||
!!! question "自 sing-box 1.14.0 起"
|
!!! question "自 sing-box 1.14.0 起"
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ type ACMECertificateProviderOptions struct {
|
|||||||
ExternalAccount *ACMEExternalAccountOptions `json:"external_account,omitempty"`
|
ExternalAccount *ACMEExternalAccountOptions `json:"external_account,omitempty"`
|
||||||
DNS01Challenge *ACMEProviderDNS01ChallengeOptions `json:"dns01_challenge,omitempty"`
|
DNS01Challenge *ACMEProviderDNS01ChallengeOptions `json:"dns01_challenge,omitempty"`
|
||||||
KeyType ACMEKeyType `json:"key_type,omitempty"`
|
KeyType ACMEKeyType `json:"key_type,omitempty"`
|
||||||
|
Profile string `json:"profile,omitempty"`
|
||||||
HTTPClient *HTTPClientOptions `json:"http_client,omitempty"`
|
HTTPClient *HTTPClientOptions `json:"http_client,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ type InboundACMEOptions struct {
|
|||||||
AlternativeTLSPort uint16 `json:"alternative_tls_port,omitempty"`
|
AlternativeTLSPort uint16 `json:"alternative_tls_port,omitempty"`
|
||||||
ExternalAccount *ACMEExternalAccountOptions `json:"external_account,omitempty"`
|
ExternalAccount *ACMEExternalAccountOptions `json:"external_account,omitempty"`
|
||||||
DNS01Challenge *ACMEDNS01ChallengeOptions `json:"dns01_challenge,omitempty"`
|
DNS01Challenge *ACMEDNS01ChallengeOptions `json:"dns01_challenge,omitempty"`
|
||||||
|
Profile string `json:"profile,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ACMEExternalAccountOptions struct {
|
type ACMEExternalAccountOptions struct {
|
||||||
|
|||||||
@@ -112,11 +112,22 @@ func NewCertificateProvider(ctx context.Context, logger log.ContextLogger, tag s
|
|||||||
config.KeySource = certmagic.StandardKeyGenerator{KeyType: keyType}
|
config.KeySource = certmagic.StandardKeyGenerator{KeyType: keyType}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
profile := options.Profile
|
||||||
|
if profile == "" && acmeServer == certmagic.LetsEncryptProductionCA {
|
||||||
|
for _, domain := range options.Domain {
|
||||||
|
if certmagic.SubjectIsIP(domain) {
|
||||||
|
profile = "shortlived"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
acmeIssuer := certmagic.ACMEIssuer{
|
acmeIssuer := certmagic.ACMEIssuer{
|
||||||
CA: acmeServer,
|
CA: acmeServer,
|
||||||
Email: options.Email,
|
Email: options.Email,
|
||||||
AccountKeyPEM: options.AccountKey,
|
AccountKeyPEM: options.AccountKey,
|
||||||
Agreed: true,
|
Agreed: true,
|
||||||
|
Profile: profile,
|
||||||
DisableHTTPChallenge: options.DisableHTTPChallenge,
|
DisableHTTPChallenge: options.DisableHTTPChallenge,
|
||||||
DisableTLSALPNChallenge: options.DisableTLSALPNChallenge,
|
DisableTLSALPNChallenge: options.DisableTLSALPNChallenge,
|
||||||
AltHTTPPort: int(options.AlternativeHTTPPort),
|
AltHTTPPort: int(options.AlternativeHTTPPort),
|
||||||
|
|||||||
Reference in New Issue
Block a user