Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
b35d19d7
Commit
b35d19d7
authored
Jul 19, 2016
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set protocol version properly (fixes #943)
parent
cf4e0c9c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
4 deletions
+30
-4
caddytls/config.go
caddytls/config.go
+5
-4
caddytls/config_test.go
caddytls/config_test.go
+22
-0
caddytls/setup.go
caddytls/setup.go
+3
-0
No files found.
caddytls/config.go
View file @
b35d19d7
...
@@ -9,11 +9,12 @@ import (
...
@@ -9,11 +9,12 @@ import (
"io/ioutil"
"io/ioutil"
"time"
"time"
"github.com/mholt/caddy"
"github.com/xenolf/lego/acme"
"log"
"log"
"net/url"
"net/url"
"strings"
"strings"
"github.com/mholt/caddy"
"github.com/xenolf/lego/acme"
)
)
// Config describes how TLS should be configured and used.
// Config describes how TLS should be configured and used.
...
@@ -322,10 +323,10 @@ func MakeTLSConfig(configs []*Config) (*tls.Config, error) {
...
@@ -322,10 +323,10 @@ func MakeTLSConfig(configs []*Config) (*tls.Config, error) {
}
}
// Go with the widest range of protocol versions
// Go with the widest range of protocol versions
if
cfg
.
ProtocolMinVersion
<
config
.
MinVersion
{
if
c
onfig
.
MinVersion
==
0
||
c
fg
.
ProtocolMinVersion
<
config
.
MinVersion
{
config
.
MinVersion
=
cfg
.
ProtocolMinVersion
config
.
MinVersion
=
cfg
.
ProtocolMinVersion
}
}
if
cfg
.
ProtocolMaxVersion
<
config
.
MaxVersion
{
if
cfg
.
ProtocolMaxVersion
>
config
.
MaxVersion
{
config
.
MaxVersion
=
cfg
.
ProtocolMaxVersion
config
.
MaxVersion
=
cfg
.
ProtocolMaxVersion
}
}
...
...
caddytls/config_test.go
View file @
b35d19d7
package
caddytls
package
caddytls
import
(
import
(
"crypto/tls"
"errors"
"errors"
"net/url"
"net/url"
"reflect"
"reflect"
"testing"
"testing"
)
)
func
TestMakeTLSConfig
(
t
*
testing
.
T
)
{
// same min and max protocol versions
configs
:=
[]
*
Config
{
{
Enabled
:
true
,
ProtocolMinVersion
:
tls
.
VersionTLS12
,
ProtocolMaxVersion
:
tls
.
VersionTLS12
,
},
}
result
,
err
:=
MakeTLSConfig
(
configs
)
if
err
!=
nil
{
t
.
Fatalf
(
"Did not expect an error, but got %v"
,
err
)
}
if
got
,
want
:=
result
.
MinVersion
,
uint16
(
tls
.
VersionTLS12
);
got
!=
want
{
t
.
Errorf
(
"Expected min version to be %x, got %x"
,
want
,
got
)
}
if
got
,
want
:=
result
.
MaxVersion
,
uint16
(
tls
.
VersionTLS12
);
got
!=
want
{
t
.
Errorf
(
"Expected max version to be %x, got %x"
,
want
,
got
)
}
}
func
TestStorageForNoURL
(
t
*
testing
.
T
)
{
func
TestStorageForNoURL
(
t
*
testing
.
T
)
{
c
:=
&
Config
{}
c
:=
&
Config
{}
if
_
,
err
:=
c
.
StorageFor
(
""
);
err
==
nil
{
if
_
,
err
:=
c
.
StorageFor
(
""
);
err
==
nil
{
...
...
caddytls/setup.go
View file @
b35d19d7
...
@@ -88,6 +88,9 @@ func setupTLS(c *caddy.Controller) error {
...
@@ -88,6 +88,9 @@ func setupTLS(c *caddy.Controller) error {
return
c
.
Errf
(
"Wrong protocol name or protocol not supported: '%s'"
,
args
[
1
])
return
c
.
Errf
(
"Wrong protocol name or protocol not supported: '%s'"
,
args
[
1
])
}
}
config
.
ProtocolMaxVersion
=
value
config
.
ProtocolMaxVersion
=
value
if
config
.
ProtocolMinVersion
>
config
.
ProtocolMaxVersion
{
return
c
.
Errf
(
"Minimum protocol version cannot be higher than maximum (reverse the order)"
)
}
case
"ciphers"
:
case
"ciphers"
:
for
c
.
NextArg
()
{
for
c
.
NextArg
()
{
value
,
ok
:=
supportedCiphersMap
[
strings
.
ToUpper
(
c
.
Val
())]
value
,
ok
:=
supportedCiphersMap
[
strings
.
ToUpper
(
c
.
Val
())]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment