mirror of
https://github.com/1f349/violet.git
synced 2024-11-24 20:31:37 +00:00
Read certificate and key for domain correctly
This commit is contained in:
parent
755e597a11
commit
c930ddff28
@ -10,7 +10,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
"path/filepath"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@ -158,8 +158,10 @@ func (c *Certs) internalCompile(m map[string]*tls.Certificate) error {
|
|||||||
|
|
||||||
// get file name and extension
|
// get file name and extension
|
||||||
name := i.Name()
|
name := i.Name()
|
||||||
ext := filepath.Ext(name)
|
if !strings.HasSuffix(name, ".cert.pem") {
|
||||||
keyName := name[:len(name)-len(ext)] + ".key"
|
continue
|
||||||
|
}
|
||||||
|
keyName := name[:len(name)-len("cert.pem")] + "key.pem"
|
||||||
|
|
||||||
// try to read cert file
|
// try to read cert file
|
||||||
certData, err := fs.ReadFile(c.cDir, name)
|
certData, err := fs.ReadFile(c.cDir, name)
|
||||||
|
@ -41,13 +41,13 @@ func TestCertsNew_Lookup(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
certDir := fstest.MapFS{
|
certDir := fstest.MapFS{
|
||||||
"example.com.pem": {
|
"example.com.cert.pem": {
|
||||||
Data: serverTls.GetCertPem(),
|
Data: serverTls.GetCertPem(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
keyDir := fstest.MapFS{
|
keyDir := fstest.MapFS{
|
||||||
"example.com.key": {
|
"example.com.key.pem": {
|
||||||
Data: serverTls.GetKeyPem(),
|
Data: serverTls.GetKeyPem(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user