From 134abbd82bb3dc1bddd831ecf4e62b68a283cd74 Mon Sep 17 00:00:00 2001
From: Alexander Neumann <alexander@bumpern.de>
Date: Sat, 25 Nov 2017 20:56:40 +0100
Subject: [PATCH] rest: Use client for creating the repository

Before, creating a new repo via REST would use the defaut HTTP client,
which is not a problem unless the server uses HTTPS and a TLS
certificate which isn't signed by a CA in the system's CA store. In this
case, all commands work except the 'init' command, which fails with a
message like "invalid certificate".
---
 internal/backend/rest/rest.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/internal/backend/rest/rest.go b/internal/backend/rest/rest.go
index 51c8e0c5c..825202f20 100644
--- a/internal/backend/rest/rest.go
+++ b/internal/backend/rest/rest.go
@@ -31,7 +31,7 @@ type restBackend struct {
 }
 
 // Open opens the REST backend with the given config.
-func Open(cfg Config, rt http.RoundTripper) (restic.Backend, error) {
+func Open(cfg Config, rt http.RoundTripper) (*restBackend, error) {
 	client := &http.Client{Transport: rt}
 
 	sem, err := backend.NewSemaphore(cfg.Connections)
@@ -72,7 +72,7 @@ func Create(cfg Config, rt http.RoundTripper) (restic.Backend, error) {
 	values.Set("create", "true")
 	url.RawQuery = values.Encode()
 
-	resp, err := http.Post(url.String(), "binary/octet-stream", strings.NewReader(""))
+	resp, err := be.client.Post(url.String(), "binary/octet-stream", strings.NewReader(""))
 	if err != nil {
 		return nil, err
 	}