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
0c69e9ed
Commit
0c69e9ed
authored
Feb 14, 2019
by
Matthew Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tlscluster'
parents
6246d4c3
0a95b5d3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
caddyhttp/httpserver/plugin.go
caddyhttp/httpserver/plugin.go
+4
-1
caddytls/config.go
caddytls/config.go
+26
-2
No files found.
caddyhttp/httpserver/plugin.go
View file @
0c69e9ed
...
...
@@ -190,7 +190,10 @@ func (h *httpContext) InspectServerBlocks(sourceFile string, serverBlocks []cadd
// Make our caddytls.Config, which has a pointer to the
// instance's certificate cache and enough information
// to use automatic HTTPS when the time comes
caddytlsConfig
:=
caddytls
.
NewConfig
(
h
.
instance
)
caddytlsConfig
,
err
:=
caddytls
.
NewConfig
(
h
.
instance
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"creating new caddytls configuration: %v"
,
err
)
}
caddytlsConfig
.
Hostname
=
addr
.
Host
caddytlsConfig
.
Manager
.
AltHTTPPort
=
altHTTPPort
caddytlsConfig
.
Manager
.
AltTLSALPNPort
=
altTLSALPNPort
...
...
caddytls/config.go
View file @
0c69e9ed
...
...
@@ -19,6 +19,8 @@ import (
"crypto/x509"
"fmt"
"io/ioutil"
"os"
"sync/atomic"
"github.com/xenolf/lego/challenge/tlsalpn01"
...
...
@@ -95,11 +97,31 @@ type Config struct {
// NewConfig returns a new Config with a pointer to the instance's
// certificate cache. You will usually need to set other fields on
// the returned Config for successful practical use.
func
NewConfig
(
inst
*
caddy
.
Instance
)
*
Config
{
func
NewConfig
(
inst
*
caddy
.
Instance
)
(
*
Config
,
error
)
{
inst
.
StorageMu
.
RLock
()
certCache
,
ok
:=
inst
.
Storage
[
CertCacheInstStorageKey
]
.
(
*
certmagic
.
Cache
)
inst
.
StorageMu
.
RUnlock
()
if
!
ok
||
certCache
==
nil
{
// set up the clustering plugin, if there is one (and there should always
// be one since this tls plugin requires it) -- this should be done exactly
// once, but we can't do it during init while plugins are still registering,
// so do it as soon as we run a setup)
if
atomic
.
CompareAndSwapInt32
(
&
clusterPluginSetup
,
0
,
1
)
{
clusterPluginName
:=
os
.
Getenv
(
"CADDY_CLUSTERING"
)
if
clusterPluginName
==
""
{
clusterPluginName
=
"file"
// name of default storage plugin
}
clusterFn
,
ok
:=
clusterProviders
[
clusterPluginName
]
if
ok
{
storage
,
err
:=
clusterFn
()
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"constructing cluster plugin %s: %v"
,
clusterPluginName
,
err
)
}
certmagic
.
DefaultStorage
=
storage
}
else
{
return
nil
,
fmt
.
Errorf
(
"unrecognized cluster plugin (was it included in the Caddy build?): %s"
,
clusterPluginName
)
}
}
certCache
=
certmagic
.
NewCache
(
certmagic
.
DefaultStorage
)
inst
.
OnShutdown
=
append
(
inst
.
OnShutdown
,
func
()
error
{
certCache
.
Stop
()
...
...
@@ -111,7 +133,7 @@ func NewConfig(inst *caddy.Instance) *Config {
}
return
&
Config
{
Manager
:
certmagic
.
NewWithCache
(
certCache
,
certmagic
.
Config
{}),
}
}
,
nil
}
// buildStandardTLSConfig converts cfg (*caddytls.Config) to a *tls.Config
...
...
@@ -519,6 +541,8 @@ var defaultCurves = []tls.CurveID{
tls
.
CurveP256
,
}
var
clusterPluginSetup
int32
// access atomically
// CertCacheInstStorageKey is the name of the key for
// accessing the certificate storage on the *caddy.Instance.
const
CertCacheInstStorageKey
=
"tls_cert_cache"
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