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
e5a89276
Commit
e5a89276
authored
Aug 06, 2016
by
elcore
Committed by
Matt Holt
Aug 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow just one TLS Protocol (Caddyfile) (#1004)
* Allow just one TLS Protocol * Fix typo
parent
2019eec5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
15 deletions
+43
-15
caddytls/setup.go
caddytls/setup.go
+21
-15
caddytls/setup_test.go
caddytls/setup_test.go
+22
-0
No files found.
caddytls/setup.go
View file @
e5a89276
...
@@ -75,9 +75,14 @@ func setupTLS(c *caddy.Controller) error {
...
@@ -75,9 +75,14 @@ func setupTLS(c *caddy.Controller) error {
config
.
KeyType
=
value
config
.
KeyType
=
value
case
"protocols"
:
case
"protocols"
:
args
:=
c
.
RemainingArgs
()
args
:=
c
.
RemainingArgs
()
if
len
(
args
)
!=
2
{
if
len
(
args
)
==
1
{
return
c
.
ArgErr
()
value
,
ok
:=
supportedProtocols
[
strings
.
ToLower
(
args
[
0
])]
if
!
ok
{
return
c
.
Errf
(
"Wrong protocol name or protocol not supported: '%s'"
,
args
[
0
])
}
}
config
.
ProtocolMinVersion
,
config
.
ProtocolMaxVersion
=
value
,
value
}
else
{
value
,
ok
:=
supportedProtocols
[
strings
.
ToLower
(
args
[
0
])]
value
,
ok
:=
supportedProtocols
[
strings
.
ToLower
(
args
[
0
])]
if
!
ok
{
if
!
ok
{
return
c
.
Errf
(
"Wrong protocol name or protocol not supported: '%s'"
,
args
[
0
])
return
c
.
Errf
(
"Wrong protocol name or protocol not supported: '%s'"
,
args
[
0
])
...
@@ -91,6 +96,7 @@ func setupTLS(c *caddy.Controller) error {
...
@@ -91,6 +96,7 @@ func setupTLS(c *caddy.Controller) error {
if
config
.
ProtocolMinVersion
>
config
.
ProtocolMaxVersion
{
if
config
.
ProtocolMinVersion
>
config
.
ProtocolMaxVersion
{
return
c
.
Errf
(
"Minimum protocol version cannot be higher than maximum (reverse the order)"
)
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
())]
...
...
caddytls/setup_test.go
View file @
e5a89276
...
@@ -269,6 +269,28 @@ func TestSetupParseWithKeyType(t *testing.T) {
...
@@ -269,6 +269,28 @@ func TestSetupParseWithKeyType(t *testing.T) {
}
}
}
}
func
TestSetupParseWithOneTLSProtocol
(
t
*
testing
.
T
)
{
params
:=
`tls {
protocols tls1.2
}`
cfg
:=
new
(
Config
)
RegisterConfigGetter
(
""
,
func
(
c
*
caddy
.
Controller
)
*
Config
{
return
cfg
})
c
:=
caddy
.
NewTestController
(
""
,
params
)
err
:=
setupTLS
(
c
)
if
err
!=
nil
{
t
.
Errorf
(
"Expected no errors, got: %v"
,
err
)
}
if
cfg
.
ProtocolMinVersion
!=
cfg
.
ProtocolMaxVersion
{
t
.
Errorf
(
"Expected ProtocolMinVersion to be the same as ProtocolMaxVersion"
)
}
if
cfg
.
ProtocolMinVersion
!=
tls
.
VersionTLS12
&&
cfg
.
ProtocolMaxVersion
!=
tls
.
VersionTLS12
{
t
.
Errorf
(
"Expected 'tls1.2 (0x0303)' as ProtocolMinVersion/ProtocolMaxVersion, got %v/%v"
,
cfg
.
ProtocolMinVersion
,
cfg
.
ProtocolMaxVersion
)
}
}
const
(
const
(
certFile
=
"test_cert.pem"
certFile
=
"test_cert.pem"
keyFile
=
"test_key.pem"
keyFile
=
"test_key.pem"
...
...
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