pkg/blobserver/remote: adds trusted certs option to remote blobserver

Allows to use self signed certificates with https endpoints.

Change-Id: I1e15bbf15b89e57c8a8cfaf85d778d912a3cc36e
This commit is contained in:
Markus Peröbner 2016-10-09 16:28:08 +02:00 committed by Brad Fitzpatrick
parent d388cab373
commit ca3118aa12
1 changed files with 10 additions and 4 deletions

View File

@ -16,20 +16,23 @@ limitations under the License.
/* /*
Package remote registers the "remote" blobserver storage type, storing Package remote registers the "remote" blobserver storage type, storing
and fetching blobs from a remote Camlistore server, speaking the HTTP and fetching blobs from a remote Camlistore server over HTTPS.
protocol.
Example low-level config: Example low-level config:
"/peer/": { "/peer/": {
"handler": "storage-remote", "handler": "storage-remote",
"handlerArgs": { "handlerArgs": {
"url": "http://10.0.0.17/base", "url": "https://some-other-server/base",
"auth": "userpass:user:pass", "auth": "userpass:user:pass",
"skipStartupCheck": false "skipStartupCheck": false
} }
}, },
The "handlerArgs" may also contain an optional "trustedCert" option to
trust a self-signed TLS certificate. The value is the 20 byte hex prefix
of the SHA-256 of the cert, as printed by the camlistored server
on start-up.
*/ */
package remote // import "camlistore.org/pkg/blobserver/remote" package remote // import "camlistore.org/pkg/blobserver/remote"
@ -61,11 +64,14 @@ func newFromConfig(_ blobserver.Loader, config jsonconfig.Obj) (storage blobserv
url := config.RequiredString("url") url := config.RequiredString("url")
auth := config.RequiredString("auth") auth := config.RequiredString("auth")
skipStartupCheck := config.OptionalBool("skipStartupCheck", false) skipStartupCheck := config.OptionalBool("skipStartupCheck", false)
trustedCert := config.OptionalString("trustedCert", "")
if err := config.Validate(); err != nil { if err := config.Validate(); err != nil {
return nil, err return nil, err
} }
client := client.New(url) client := client.New(url,
client.OptionTrustedCert(trustedCert),
)
if err = client.SetupAuthFromString(auth); err != nil { if err = client.SetupAuthFromString(auth); err != nil {
return nil, err return nil, err
} }