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
b3783161
Commit
b3783161
authored
May 18, 2015
by
Guilherme Rezende
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace c.ArgErr with c.Err in tls when is the case
parent
a94c7dd7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
5 deletions
+41
-5
config/setup/tls.go
config/setup/tls.go
+10
-5
config/setup/tls_test.go
config/setup/tls_test.go
+31
-0
No files found.
config/setup/tls.go
View file @
b3783161
...
@@ -64,19 +64,20 @@ func TLS(c *Controller) (middleware.Middleware, error) {
...
@@ -64,19 +64,20 @@ func TLS(c *Controller) (middleware.Middleware, error) {
}
}
value
,
ok
:=
supportedProtocols
[
strings
.
ToLower
(
args
[
0
])]
value
,
ok
:=
supportedProtocols
[
strings
.
ToLower
(
args
[
0
])]
if
!
ok
{
if
!
ok
{
return
nil
,
c
.
ArgErr
()
return
nil
,
c
.
Errf
(
"Wrong protocol name or protocol not supported '%s'"
,
c
.
Val
())
}
}
c
.
TLS
.
ProtocolMinVersion
=
value
c
.
TLS
.
ProtocolMinVersion
=
value
value
,
ok
=
supportedProtocols
[
strings
.
ToLower
(
args
[
1
])]
value
,
ok
=
supportedProtocols
[
strings
.
ToLower
(
args
[
1
])]
if
!
ok
{
if
!
ok
{
return
nil
,
c
.
ArgErr
(
)
return
nil
,
c
.
Errf
(
"Wrong protocol name or protocol not supported '%s'"
,
c
.
Val
()
)
}
}
c
.
TLS
.
ProtocolMaxVersion
=
value
c
.
TLS
.
ProtocolMaxVersion
=
value
case
"ciphers"
:
case
"ciphers"
:
for
c
.
NextArg
()
{
for
c
.
NextArg
()
{
value
,
ok
:=
supportedCiphers
[
strings
.
ToUpper
(
c
.
Val
())]
value
,
ok
:=
supportedCiphers
[
strings
.
ToUpper
(
c
.
Val
())]
if
!
ok
{
if
!
ok
{
return
nil
,
c
.
ArgErr
(
)
return
nil
,
c
.
Errf
(
"Wrong cipher name or cipher not supported '%s'"
,
c
.
Val
()
)
}
}
c
.
TLS
.
Ciphers
=
append
(
c
.
TLS
.
Ciphers
,
value
)
c
.
TLS
.
Ciphers
=
append
(
c
.
TLS
.
Ciphers
,
value
)
}
}
...
@@ -84,9 +85,13 @@ func TLS(c *Controller) (middleware.Middleware, error) {
...
@@ -84,9 +85,13 @@ func TLS(c *Controller) (middleware.Middleware, error) {
if
!
c
.
NextArg
()
{
if
!
c
.
NextArg
()
{
return
nil
,
c
.
ArgErr
()
return
nil
,
c
.
ArgErr
()
}
}
c
.
TLS
.
CacheSize
,
_
=
strconv
.
Atoi
(
c
.
Val
())
size
,
err
:=
strconv
.
Atoi
(
c
.
Val
())
if
err
!=
nil
{
return
nil
,
c
.
Errf
(
"Cache parameter should be an number '%s': %v"
,
c
.
Val
(),
err
)
}
c
.
TLS
.
CacheSize
=
size
default
:
default
:
return
nil
,
c
.
ArgErr
(
)
return
nil
,
c
.
Errf
(
"Unknown keyword '%s'"
)
}
}
}
}
}
}
...
...
config/setup/tls_test.go
View file @
b3783161
...
@@ -76,3 +76,34 @@ func TestTLSParseWithOptionalParams(t *testing.T) {
...
@@ -76,3 +76,34 @@ func TestTLSParseWithOptionalParams(t *testing.T) {
t
.
Errorf
(
"Expected CacheSize 128, got %v"
,
c
.
TLS
.
CacheSize
)
t
.
Errorf
(
"Expected CacheSize 128, got %v"
,
c
.
TLS
.
CacheSize
)
}
}
}
}
func
TestTLSParseWithWrongOptionalParams
(
t
*
testing
.
T
)
{
params
:=
`tls cert.crt cert.key {
cache a
}`
c
:=
newTestController
(
params
)
_
,
err
:=
TLS
(
c
)
if
err
==
nil
{
t
.
Errorf
(
"Expected errors, but no error returned"
)
}
// Test protocols wrong params
params
=
`tls cert.crt cert.key {
protocols ssl tls
}`
c
=
newTestController
(
params
)
_
,
err
=
TLS
(
c
)
if
err
==
nil
{
t
.
Errorf
(
"Expected errors, but no error returned"
)
}
// Test ciphers wrong params
params
=
`tls cert.crt cert.key {
ciphers not-valid-cipher
}`
c
=
newTestController
(
params
)
_
,
err
=
TLS
(
c
)
if
err
==
nil
{
t
.
Errorf
(
"Expected errors, but no error returned"
)
}
}
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