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
f3721c10
Commit
f3721c10
authored
Jun 24, 2017
by
Jason Hutchinson
Committed by
Matt Holt
Jun 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tls: add optional 'ca' tls directive, closes #1689 (#1699)
parent
3e2b1d14
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
caddytls/setup.go
caddytls/setup.go
+6
-0
caddytls/setup_test.go
caddytls/setup_test.go
+40
-0
No files found.
caddytls/setup.go
View file @
f3721c10
...
...
@@ -66,6 +66,12 @@ func setupTLS(c *caddy.Controller) error {
for
c
.
NextBlock
()
{
hadBlock
=
true
switch
c
.
Val
()
{
case
"ca"
:
arg
:=
c
.
RemainingArgs
()
if
len
(
arg
)
!=
1
{
return
c
.
ArgErr
()
}
config
.
CAUrl
=
arg
[
0
]
case
"key_type"
:
arg
:=
c
.
RemainingArgs
()
value
,
ok
:=
supportedKeyTypes
[
strings
.
ToUpper
(
arg
[
0
])]
...
...
caddytls/setup_test.go
View file @
f3721c10
...
...
@@ -277,6 +277,46 @@ func TestSetupParseWithClientAuth(t *testing.T) {
}
}
func
TestSetupParseWithCAUrl
(
t
*
testing
.
T
)
{
testURL
:=
"https://acme-staging.api.letsencrypt.org/directory"
for
caseNumber
,
caseData
:=
range
[]
struct
{
params
string
expectedErr
bool
expectedCAUrl
string
}{
// Test working case
{
`tls {
ca `
+
testURL
+
`
}`
,
false
,
testURL
},
// Test too few args
{
`tls {
ca
}`
,
true
,
""
},
// Test too many args
{
`tls {
ca 1 2
}`
,
true
,
""
},
}
{
cfg
:=
new
(
Config
)
RegisterConfigGetter
(
""
,
func
(
c
*
caddy
.
Controller
)
*
Config
{
return
cfg
})
c
:=
caddy
.
NewTestController
(
""
,
caseData
.
params
)
err
:=
setupTLS
(
c
)
if
caseData
.
expectedErr
{
if
err
==
nil
{
t
.
Errorf
(
"In case %d: Expected an error, got: %v"
,
caseNumber
,
err
)
}
continue
}
if
err
!=
nil
{
t
.
Errorf
(
"In case %d: Expected no errors, got: %v"
,
caseNumber
,
err
)
}
if
cfg
.
CAUrl
!=
caseData
.
expectedCAUrl
{
t
.
Errorf
(
"Expected '%v' as CAUrl, got %#v"
,
caseData
.
expectedCAUrl
,
cfg
.
CAUrl
)
}
}
}
func
TestSetupParseWithKeyType
(
t
*
testing
.
T
)
{
params
:=
`tls {
key_type p384
...
...
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