Skip to content

Commit 3d7371a

Browse files
committed
Updated go-certificates & go-driver to latest versions
1 parent b13830d commit 3d7371a

37 files changed

+1051
-110
lines changed

deps/github.com/arangodb-helper/go-certificates/cli/certificates.go

+32-18
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ const (
4343
// Client authentication valid for defaults
4444
defaultClientAuthValidFor = time.Hour * 24 * 365 * 1 // 1 years
4545
defaultClientAuthCAValidFor = time.Hour * 24 * 365 * 15 // 15 years
46+
// TLS curve defaults
47+
defaultTLSCurve = "P256"
48+
defaultClientAuthCurve = "P521"
4649
)
4750

4851
var (
@@ -148,11 +151,11 @@ type createCAOptions struct {
148151
ecdsaCurve string
149152
}
150153

151-
func (o *createCAOptions) ConfigureFlags(f *pflag.FlagSet, defaultFName string, defaultValidFor time.Duration) {
154+
func (o *createCAOptions) ConfigureFlags(f *pflag.FlagSet, defaultFName string, defaultValidFor time.Duration, defaultCurve string) {
152155
f.StringVar(&o.certFile, "cert", defaultFName+".crt", "Filename of the generated CA certificate")
153156
f.StringVar(&o.keyFile, "key", defaultFName+".key", "Filename of the generated CA private key")
154157
f.DurationVar(&o.validFor, "validfor", defaultValidFor, "Lifetime of the certificate until expiration")
155-
f.StringVar(&o.ecdsaCurve, "curve", "P521", "ECDSA curve used for private key")
158+
f.StringVar(&o.ecdsaCurve, "curve", defaultCurve, "ECDSA curve used for private key")
156159
}
157160

158161
func (o *createCAOptions) CreateCA() {
@@ -184,13 +187,13 @@ type createCertificateBaseOptions struct {
184187
ecdsaCurve string
185188
}
186189

187-
func (o *createCertificateBaseOptions) ConfigureFlags(f *pflag.FlagSet, defaultCAFName, defaultFName string, defaultValidFor time.Duration) {
190+
func (o *createCertificateBaseOptions) ConfigureFlags(f *pflag.FlagSet, defaultCAFName, defaultFName string, defaultValidFor time.Duration, defaultCurve string) {
188191
f.StringVar(&o.caCertFile, "cacert", defaultCAFName+".crt", "File containing TLS CA certificate")
189192
f.StringVar(&o.caKeyFile, "cakey", defaultCAFName+".key", "File containing TLS CA private key")
190193
f.StringSliceVar(&o.hosts, "host", nil, "Host name to include in the certificate")
191194
f.StringSliceVar(&o.emailAddresses, "email", nil, "Email address to include in the certificate")
192195
f.DurationVar(&o.validFor, "validfor", defaultValidFor, "Lifetime of the certificate until expiration")
193-
f.StringVar(&o.ecdsaCurve, "curve", "P521", "ECDSA curve used for private key")
196+
f.StringVar(&o.ecdsaCurve, "curve", defaultCurve, "ECDSA curve used for private key")
194197
}
195198

196199
// Create a certificate from given options.
@@ -206,8 +209,8 @@ func (o *createCertificateBaseOptions) CreateCertificate(isClientAuth bool) (str
206209

207210
// Create certificate
208211
options := certificates.CreateCertificateOptions{
209-
Hosts: o.hosts,
210-
EmailAddresses: o.emailAddresses,
212+
Hosts: removeEmptyStrings(o.hosts),
213+
EmailAddresses: removeEmptyStrings(o.emailAddresses),
211214
ValidFor: o.validFor,
212215
ECDSACurve: o.ecdsaCurve,
213216
IsClientAuth: isClientAuth,
@@ -225,8 +228,8 @@ type createKeyFileOptions struct {
225228
keyFile string
226229
}
227230

228-
func (o *createKeyFileOptions) ConfigureFlags(f *pflag.FlagSet, defaultCAFName, defaultFName string, defaultValidFor time.Duration) {
229-
o.createCertificateBaseOptions.ConfigureFlags(f, defaultCAFName, defaultFName, defaultValidFor)
231+
func (o *createKeyFileOptions) ConfigureFlags(f *pflag.FlagSet, defaultCAFName, defaultFName string, defaultValidFor time.Duration, defaultCurve string) {
232+
o.createCertificateBaseOptions.ConfigureFlags(f, defaultCAFName, defaultFName, defaultValidFor, defaultCurve)
230233
f.StringVar(&o.keyFile, "keyfile", defaultFName+".keyfile", "Filename of keyfile to generate")
231234
}
232235

@@ -247,8 +250,8 @@ type createCertificateOptions struct {
247250
keyFile string
248251
}
249252

250-
func (o *createCertificateOptions) ConfigureFlags(f *pflag.FlagSet, defaultCAFName, defaultFName string, defaultValidFor time.Duration) {
251-
o.createCertificateBaseOptions.ConfigureFlags(f, defaultCAFName, defaultFName, defaultValidFor)
253+
func (o *createCertificateOptions) ConfigureFlags(f *pflag.FlagSet, defaultCAFName, defaultFName string, defaultValidFor time.Duration, defaultCurve string) {
254+
o.createCertificateBaseOptions.ConfigureFlags(f, defaultCAFName, defaultFName, defaultValidFor, defaultCurve)
252255
f.StringVar(&o.certFile, "cert", defaultFName+".crt", "Filename of the generated certificate")
253256
f.StringVar(&o.keyFile, "key", defaultFName+".key", "Filename of the generated private key")
254257
}
@@ -272,8 +275,8 @@ type createKeystoreOptions struct {
272275
alias string
273276
}
274277

275-
func (o *createKeystoreOptions) ConfigureFlags(f *pflag.FlagSet, defaultCAFName, defaultFName string, defaultValidFor time.Duration) {
276-
o.createCertificateBaseOptions.ConfigureFlags(f, defaultCAFName, defaultFName, defaultValidFor)
278+
func (o *createKeystoreOptions) ConfigureFlags(f *pflag.FlagSet, defaultCAFName, defaultFName string, defaultValidFor time.Duration, defaultCurve string) {
279+
o.createCertificateBaseOptions.ConfigureFlags(f, defaultCAFName, defaultFName, defaultValidFor, defaultCurve)
277280
f.StringVar(&o.keystoreFile, "keystore", defaultFName+".jks", "Filename of the generated keystore")
278281
f.StringVar(&o.keystorePassword, "keystore-password", "", "Password of the generated keystore")
279282
f.StringVar(&o.alias, "alias", "", "Aliases use to store the certificate under in the keystore")
@@ -317,12 +320,12 @@ func AddCommands(cmd *cobra.Command, logFatalFunc func(error, string), showUsage
317320
cmdCreateClientAuth.AddCommand(cmdCreateClientAuthKeyFile)
318321

319322
createOptions.jwtsecret.ConfigureFlags(cmdCreateJWTSecret.Flags())
320-
createOptions.tls.ca.ConfigureFlags(cmdCreateTLSCA.Flags(), "tls-ca", defaultTLSCAValidFor)
321-
createOptions.tls.keyFile.ConfigureFlags(cmdCreateTLSKeyFile.Flags(), "tls-ca", "tls", defaultTLSValidFor)
322-
createOptions.tls.certificate.ConfigureFlags(cmdCreateTLSCertificate.Flags(), "tls-ca", "tls", defaultTLSValidFor)
323-
createOptions.tls.keystore.ConfigureFlags(cmdCreateTLSKeystore.Flags(), "tls-ca", "tls", defaultTLSValidFor)
324-
createOptions.clientAuth.ca.ConfigureFlags(cmdCreateClientAuthCA.Flags(), "client-auth-ca", defaultClientAuthCAValidFor)
325-
createOptions.clientAuth.keyFile.ConfigureFlags(cmdCreateClientAuthKeyFile.Flags(), "client-auth-ca", "client-auth", defaultClientAuthValidFor)
323+
createOptions.tls.ca.ConfigureFlags(cmdCreateTLSCA.Flags(), "tls-ca", defaultTLSCAValidFor, defaultTLSCurve)
324+
createOptions.tls.keyFile.ConfigureFlags(cmdCreateTLSKeyFile.Flags(), "tls-ca", "tls", defaultTLSValidFor, defaultTLSCurve)
325+
createOptions.tls.certificate.ConfigureFlags(cmdCreateTLSCertificate.Flags(), "tls-ca", "tls", defaultTLSValidFor, defaultTLSCurve)
326+
createOptions.tls.keystore.ConfigureFlags(cmdCreateTLSKeystore.Flags(), "tls-ca", "tls", defaultTLSValidFor, defaultTLSCurve)
327+
createOptions.clientAuth.ca.ConfigureFlags(cmdCreateClientAuthCA.Flags(), "client-auth-ca", defaultClientAuthCAValidFor, defaultClientAuthCurve)
328+
createOptions.clientAuth.keyFile.ConfigureFlags(cmdCreateClientAuthKeyFile.Flags(), "client-auth-ca", "client-auth", defaultClientAuthValidFor, defaultClientAuthCurve)
326329
}
327330

328331
// Cobra run function using the usage of the given command
@@ -401,3 +404,14 @@ func mustReadFile(filename string, flagName string) string {
401404
}
402405
return string(content)
403406
}
407+
408+
// removeEmptyStrings returns the given slice without all empty entries removed.
409+
func removeEmptyStrings(slice []string) []string {
410+
result := make([]string, 0, len(slice))
411+
for _, x := range slice {
412+
if x != "" {
413+
result = append(result, x)
414+
}
415+
}
416+
return result
417+
}

deps/github.com/arangodb-helper/go-certificates/create.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const (
4444
)
4545

4646
type CreateCertificateOptions struct {
47+
Subject *pkix.Name // If set, this name is used for the subject of the certificate and CommonName is ignored.
4748
CommonName string // Common name set in the certificate. If not specified, defaults to first email address, then first host and if all not set 'ArangoDB'.
4849
Hosts []string // Comma-separated hostnames and IPs to generate a certificate for
4950
EmailAddresses []string // List of email address to include in the certificate as alternative name
@@ -101,14 +102,18 @@ func CreateCertificate(options CreateCertificateOptions, ca *CA) (string, string
101102
} else if len(options.Hosts) > 0 {
102103
commonName = options.Hosts[0]
103104
}
105+
var subject pkix.Name
106+
if options.Subject != nil {
107+
subject = *options.Subject
108+
} else {
109+
subject.CommonName = commonName
110+
subject.Organization = []string{"ArangoDB"}
111+
}
104112
template := x509.Certificate{
105113
SerialNumber: serialNumber,
106-
Subject: pkix.Name{
107-
CommonName: commonName,
108-
Organization: []string{"ArangoDB"},
109-
},
110-
NotBefore: notBefore,
111-
NotAfter: notAfter,
114+
Subject: subject,
115+
NotBefore: notBefore,
116+
NotAfter: notAfter,
112117

113118
KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
114119
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageAny},

deps/github.com/arangodb/go-driver/.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ language: go
77

88
env:
99
- TEST_SUITE=run-tests-http
10-
- TEST_SUITE=run-tests-single ARANGODB=arangodb:3.1
10+
- TEST_SUITE=run-tests-single ARANGODB=arangodb:3.2
1111
- TEST_SUITE=run-tests-single ARANGODB=arangodb/arangodb:latest
1212
- TEST_SUITE=run-tests-single ARANGODB=arangodb/arangodb-preview:latest
1313

deps/github.com/arangodb/go-driver/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SCRIPTDIR := $(shell pwd)
33
ROOTDIR := $(shell cd $(SCRIPTDIR) && pwd)
44

55
GOBUILDDIR := $(SCRIPTDIR)/.gobuild
6-
GOVERSION := 1.9.2-alpine
6+
GOVERSION := 1.10.1-alpine
77
TMPDIR := $(GOBUILDDIR)
88

99
ifndef ARANGODB
@@ -292,6 +292,7 @@ __test_go_test:
292292
--net=$(TEST_NET) \
293293
-v $(ROOTDIR):/usr/code \
294294
-e GOPATH=/usr/code/.gobuild \
295+
-e GOCACHE=off \
295296
-e TEST_ENDPOINTS=$(TEST_ENDPOINTS) \
296297
-e TEST_AUTHENTICATION=$(TEST_AUTHENTICATION) \
297298
-e TEST_CONNECTION=$(TEST_CONNECTION) \

deps/github.com/arangodb/go-driver/agency/doc.go

+15-16
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,19 @@
2020
// Author Ewout Prangsma
2121
//
2222

23-
package agency
23+
/*
24+
Package agency provides an API to access the ArangoDB agency (it is unlikely that you need this package directly).
2425
25-
//
26-
// The Agency is fault-tolerant and highly-available key-value store
27-
// that is used to store critical, low-level information about
28-
// an ArangoDB cluster.
29-
//
30-
// The API provided in this package gives access to the Agency.
31-
//
32-
// THIS API IS NOT USED FOR NORMAL DATABASE ACCESS.
33-
//
34-
// Reasons for using this API are:
35-
// - You want to make use of an indepent Agency as your own HA key-value store.
36-
// - You want access to low-level information of your database. USE WITH GREAT CARE!
37-
//
38-
// WARNING: Messing around in the Agency can quickly lead to a corrupt database!
39-
//
26+
The Agency is fault-tolerant and highly-available key-value store
27+
that is used to store critical, low-level information about
28+
an ArangoDB cluster.
29+
30+
THIS API IS NOT USED FOR NORMAL DATABASE ACCESS.
31+
32+
Reasons for using this API are:
33+
- You want to make use of an indepent Agency as your own HA key-value store.
34+
- You want access to low-level information of your database. USE WITH GREAT CARE!
35+
36+
WARNING: Messing around in the Agency can quickly lead to a corrupt database!
37+
*/
38+
package agency
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2018 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
// Author Ewout Prangsma
21+
//
22+
23+
/*
24+
Package cluster implements a driver.Connection that provides cluster failover support (it is not intended to be used directly).
25+
*/
26+
package cluster

deps/github.com/arangodb/go-driver/collection_document_impl.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (c *collection) CreateDocument(ctx context.Context, document interface{}) (
103103
if err != nil {
104104
return DocumentMeta{}, WithStack(err)
105105
}
106-
if err := resp.CheckStatus(cs.okStatus(201, 202)); err != nil {
106+
if err := resp.CheckStatus(201, 202); err != nil {
107107
return DocumentMeta{}, WithStack(err)
108108
}
109109
if cs.Silent {
@@ -155,7 +155,7 @@ func (c *collection) CreateDocuments(ctx context.Context, documents interface{})
155155
if err != nil {
156156
return nil, nil, WithStack(err)
157157
}
158-
if err := resp.CheckStatus(cs.okStatus(201, 202)); err != nil {
158+
if err := resp.CheckStatus(201, 202); err != nil {
159159
return nil, nil, WithStack(err)
160160
}
161161
if cs.Silent {
@@ -196,7 +196,7 @@ func (c *collection) UpdateDocument(ctx context.Context, key string, update inte
196196
if err != nil {
197197
return DocumentMeta{}, WithStack(err)
198198
}
199-
if err := resp.CheckStatus(cs.okStatus(201, 202)); err != nil {
199+
if err := resp.CheckStatus(201, 202); err != nil {
200200
return DocumentMeta{}, WithStack(err)
201201
}
202202
if cs.Silent {
@@ -264,7 +264,7 @@ func (c *collection) UpdateDocuments(ctx context.Context, keys []string, updates
264264
if err != nil {
265265
return nil, nil, WithStack(err)
266266
}
267-
if err := resp.CheckStatus(cs.okStatus(201, 202)); err != nil {
267+
if err := resp.CheckStatus(201, 202); err != nil {
268268
return nil, nil, WithStack(err)
269269
}
270270
if cs.Silent {
@@ -305,7 +305,7 @@ func (c *collection) ReplaceDocument(ctx context.Context, key string, document i
305305
if err != nil {
306306
return DocumentMeta{}, WithStack(err)
307307
}
308-
if err := resp.CheckStatus(cs.okStatus(201, 202)); err != nil {
308+
if err := resp.CheckStatus(201, 202); err != nil {
309309
return DocumentMeta{}, WithStack(err)
310310
}
311311
if cs.Silent {
@@ -373,7 +373,7 @@ func (c *collection) ReplaceDocuments(ctx context.Context, keys []string, docume
373373
if err != nil {
374374
return nil, nil, WithStack(err)
375375
}
376-
if err := resp.CheckStatus(cs.okStatus(201, 202)); err != nil {
376+
if err := resp.CheckStatus(201, 202); err != nil {
377377
return nil, nil, WithStack(err)
378378
}
379379
if cs.Silent {
@@ -407,7 +407,7 @@ func (c *collection) RemoveDocument(ctx context.Context, key string) (DocumentMe
407407
if err != nil {
408408
return DocumentMeta{}, WithStack(err)
409409
}
410-
if err := resp.CheckStatus(cs.okStatus(200, 202)); err != nil {
410+
if err := resp.CheckStatus(200, 202); err != nil {
411411
return DocumentMeta{}, WithStack(err)
412412
}
413413
if cs.Silent {
@@ -456,7 +456,7 @@ func (c *collection) RemoveDocuments(ctx context.Context, keys []string) (Docume
456456
if err != nil {
457457
return nil, nil, WithStack(err)
458458
}
459-
if err := resp.CheckStatus(cs.okStatus(201, 202)); err != nil {
459+
if err := resp.CheckStatus(200, 202); err != nil {
460460
return nil, nil, WithStack(err)
461461
}
462462
if cs.Silent {

deps/github.com/arangodb/go-driver/context.go

-10
Original file line numberDiff line numberDiff line change
@@ -359,16 +359,6 @@ func applyContextSettings(ctx context.Context, req Request) contextSettings {
359359
return result
360360
}
361361

362-
// okStatus returns one of the given status codes depending on the WaitForSync field value.
363-
// If WaitForSync==true, statusWithWaitForSync is returned, otherwise statusWithoutWaitForSync is returned.
364-
func (cs contextSettings) okStatus(statusWithWaitForSync, statusWithoutWaitForSync int) int {
365-
if cs.WaitForSync {
366-
return statusWithWaitForSync
367-
} else {
368-
return statusWithoutWaitForSync
369-
}
370-
}
371-
372362
// contextOrBackground returns the given context if it is not nil.
373363
// Returns context.Background() otherwise.
374364
func contextOrBackground(ctx context.Context) context.Context {

deps/github.com/arangodb/go-driver/edge_collection_documents_impl.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (c *edgeCollection) createDocument(ctx context.Context, document interface{
103103
if err != nil {
104104
return DocumentMeta{}, cs, WithStack(err)
105105
}
106-
if err := resp.CheckStatus(cs.okStatus(201, 202)); err != nil {
106+
if err := resp.CheckStatus(201, 202); err != nil {
107107
return DocumentMeta{}, cs, WithStack(err)
108108
}
109109
if cs.Silent {
@@ -318,7 +318,7 @@ func (c *edgeCollection) replaceDocument(ctx context.Context, key string, docume
318318
if err != nil {
319319
return DocumentMeta{}, cs, WithStack(err)
320320
}
321-
if err := resp.CheckStatus(cs.okStatus(201, 202)); err != nil {
321+
if err := resp.CheckStatus(201, 202); err != nil {
322322
return DocumentMeta{}, cs, WithStack(err)
323323
}
324324
if cs.Silent {
@@ -433,7 +433,7 @@ func (c *edgeCollection) removeDocument(ctx context.Context, key string) (Docume
433433
if err != nil {
434434
return DocumentMeta{}, cs, WithStack(err)
435435
}
436-
if err := resp.CheckStatus(cs.okStatus(200, 202)); err != nil {
436+
if err := resp.CheckStatus(200, 202); err != nil {
437437
return DocumentMeta{}, cs, WithStack(err)
438438
}
439439
if cs.Silent {

deps/github.com/arangodb/go-driver/encode-go_1_8.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// Author Ewout Prangsma
2121
//
2222

23-
// +build "go1.8"
23+
// +build go1.8
2424

2525
package driver
2626

@@ -33,5 +33,6 @@ func pathEscape(s string) string {
3333

3434
// pathUnescape unescapes the given value for use in a URL path.
3535
func pathUnescape(s string) string {
36-
return url.PathUnescape(s)
36+
r, _ := url.PathUnescape(s)
37+
return r
3738
}

deps/github.com/arangodb/go-driver/encode.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// Author Ewout Prangsma
2121
//
2222

23-
// +build !"go1.8"
23+
// +build !go1.8
2424

2525
package driver
2626

0 commit comments

Comments
 (0)