summaryrefslogtreecommitdiff
path: root/vendor/github.com/googleapis
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/googleapis')
-rw-r--r--vendor/github.com/googleapis/enterprise-certificate-proxy/client/client.go37
-rw-r--r--vendor/github.com/googleapis/enterprise-certificate-proxy/client/util/util.go26
-rw-r--r--vendor/github.com/googleapis/gax-go/v2/.release-please-manifest.json2
-rw-r--r--vendor/github.com/googleapis/gax-go/v2/CHANGES.md7
-rw-r--r--vendor/github.com/googleapis/gax-go/v2/apierror/apierror.go11
-rw-r--r--vendor/github.com/googleapis/gax-go/v2/internal/version.go2
6 files changed, 60 insertions, 25 deletions
diff --git a/vendor/github.com/googleapis/enterprise-certificate-proxy/client/client.go b/vendor/github.com/googleapis/enterprise-certificate-proxy/client/client.go
index aecaff5..b3283b8 100644
--- a/vendor/github.com/googleapis/enterprise-certificate-proxy/client/client.go
+++ b/vendor/github.com/googleapis/enterprise-certificate-proxy/client/client.go
@@ -1,6 +1,15 @@
// Copyright 2022 Google LLC.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
// Package client is a cross-platform client for the signer binary (a.k.a."EnterpriseCertSigner").
//
@@ -13,10 +22,9 @@ import (
"crypto/rsa"
"crypto/x509"
"encoding/gob"
+ "errors"
"fmt"
"io"
- "io/ioutil"
- "log"
"net/rpc"
"os"
"os/exec"
@@ -44,17 +52,6 @@ func (c *Connection) Close() error {
return werr
}
-// If ECP Logging is enabled return true
-// Otherwise return false
-func enableECPLogging() bool {
- if os.Getenv("ENABLE_ENTERPRISE_CERTIFICATE_LOGS") != "" {
- return true
- }
-
- log.SetOutput(ioutil.Discard)
- return false
-}
-
func init() {
gob.Register(crypto.SHA256)
gob.Register(&rsa.PSSOptions{})
@@ -87,7 +84,7 @@ func (k *Key) Close() error {
}
// Wait for cmd to exit and release resources. Since the process is forcefully killed, this
// will return a non-nil error (varies by OS), which we will ignore.
- k.cmd.Wait()
+ _ = k.cmd.Wait()
// The Pipes connecting the RPC client should have been closed when the signer subprocess was killed.
// Calling `k.client.Close()` before `k.cmd.Process.Kill()` or `k.cmd.Wait()` _will_ cause a segfault.
if err := k.client.Close(); err.Error() != "close |0: file already closed" {
@@ -110,6 +107,10 @@ func (k *Key) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) (signed [
return
}
+// ErrCredUnavailable is a sentinel error that indicates ECP Cred is unavailable,
+// possibly due to missing config or missing binary path.
+var ErrCredUnavailable = errors.New("Cred is unavailable")
+
// Cred spawns a signer subprocess that listens on stdin/stdout to perform certificate
// related operations, including signing messages with the private key.
//
@@ -118,12 +119,14 @@ func (k *Key) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) (signed [
//
// The config file also specifies which certificate the signer should use.
func Cred(configFilePath string) (*Key, error) {
- enableECPLogging()
if configFilePath == "" {
configFilePath = util.GetDefaultConfigFilePath()
}
enterpriseCertSignerPath, err := util.LoadSignerBinaryPath(configFilePath)
if err != nil {
+ if errors.Is(err, util.ErrConfigUnavailable) {
+ return nil, ErrCredUnavailable
+ }
return nil, err
}
k := &Key{
diff --git a/vendor/github.com/googleapis/enterprise-certificate-proxy/client/util/util.go b/vendor/github.com/googleapis/enterprise-certificate-proxy/client/util/util.go
index ccef527..1640ec1 100644
--- a/vendor/github.com/googleapis/enterprise-certificate-proxy/client/util/util.go
+++ b/vendor/github.com/googleapis/enterprise-certificate-proxy/client/util/util.go
@@ -1,10 +1,23 @@
+// Copyright 2022 Google LLC.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
// Package util provides helper functions for the client.
package util
import (
"encoding/json"
"errors"
- "io/ioutil"
+ "io"
"os"
"os/user"
"path/filepath"
@@ -23,14 +36,21 @@ type Libs struct {
ECP string `json:"ecp"`
}
+// ErrConfigUnavailable is a sentinel error that indicates ECP config is unavailable,
+// possibly due to entire config missing or missing binary path.
+var ErrConfigUnavailable = errors.New("Config is unavailable")
+
// LoadSignerBinaryPath retrieves the path of the signer binary from the config file.
func LoadSignerBinaryPath(configFilePath string) (path string, err error) {
jsonFile, err := os.Open(configFilePath)
if err != nil {
+ if errors.Is(err, os.ErrNotExist) {
+ return "", ErrConfigUnavailable
+ }
return "", err
}
- byteValue, err := ioutil.ReadAll(jsonFile)
+ byteValue, err := io.ReadAll(jsonFile)
if err != nil {
return "", err
}
@@ -41,7 +61,7 @@ func LoadSignerBinaryPath(configFilePath string) (path string, err error) {
}
signerBinaryPath := config.Libs.ECP
if signerBinaryPath == "" {
- return "", errors.New("signer binary path is missing")
+ return "", ErrConfigUnavailable
}
return signerBinaryPath, nil
}
diff --git a/vendor/github.com/googleapis/gax-go/v2/.release-please-manifest.json b/vendor/github.com/googleapis/gax-go/v2/.release-please-manifest.json
index d88960b..1029563 100644
--- a/vendor/github.com/googleapis/gax-go/v2/.release-please-manifest.json
+++ b/vendor/github.com/googleapis/gax-go/v2/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- "v2": "2.7.0"
+ "v2": "2.7.1"
}
diff --git a/vendor/github.com/googleapis/gax-go/v2/CHANGES.md b/vendor/github.com/googleapis/gax-go/v2/CHANGES.md
index b75170f..41a7ca9 100644
--- a/vendor/github.com/googleapis/gax-go/v2/CHANGES.md
+++ b/vendor/github.com/googleapis/gax-go/v2/CHANGES.md
@@ -1,5 +1,12 @@
# Changelog
+## [2.7.1](https://github.com/googleapis/gax-go/compare/v2.7.0...v2.7.1) (2023-03-06)
+
+
+### Bug Fixes
+
+* **v2/apierror:** return Unknown GRPCStatus when err source is HTTP ([#260](https://github.com/googleapis/gax-go/issues/260)) ([043b734](https://github.com/googleapis/gax-go/commit/043b73437a240a91229207fb3ee52a9935a36f23)), refs [#254](https://github.com/googleapis/gax-go/issues/254)
+
## [2.7.0](https://github.com/googleapis/gax-go/compare/v2.6.0...v2.7.0) (2022-11-02)
diff --git a/vendor/github.com/googleapis/gax-go/v2/apierror/apierror.go b/vendor/github.com/googleapis/gax-go/v2/apierror/apierror.go
index aa6be13..ed862c8 100644
--- a/vendor/github.com/googleapis/gax-go/v2/apierror/apierror.go
+++ b/vendor/github.com/googleapis/gax-go/v2/apierror/apierror.go
@@ -39,6 +39,7 @@ import (
jsonerror "github.com/googleapis/gax-go/v2/apierror/internal/proto"
"google.golang.org/api/googleapi"
"google.golang.org/genproto/googleapis/rpc/errdetails"
+ "google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
@@ -197,12 +198,12 @@ func (a *APIError) Unwrap() error {
// Error returns a readable representation of the APIError.
func (a *APIError) Error() string {
var msg string
- if a.status != nil {
- msg = a.err.Error()
- } else if a.httpErr != nil {
+ if a.httpErr != nil {
// Truncate the googleapi.Error message because it dumps the Details in
// an ugly way.
msg = fmt.Sprintf("googleapi: Error %d: %s", a.httpErr.Code, a.httpErr.Message)
+ } else if a.status != nil {
+ msg = a.err.Error()
}
return strings.TrimSpace(fmt.Sprintf("%s\n%s", msg, a.details))
}
@@ -236,6 +237,9 @@ func (a *APIError) Metadata() map[string]string {
// setDetailsFromError parses a Status error or a googleapi.Error
// and sets status and details or httpErr and details, respectively.
// It returns false if neither Status nor googleapi.Error can be parsed.
+// When err is a googleapi.Error, the status of the returned error will
+// be set to an Unknown error, rather than nil, since a nil code is
+// interpreted as OK in the gRPC status package.
func (a *APIError) setDetailsFromError(err error) bool {
st, isStatus := status.FromError(err)
var herr *googleapi.Error
@@ -248,6 +252,7 @@ func (a *APIError) setDetailsFromError(err error) bool {
case isHTTPErr:
a.httpErr = herr
a.details = parseHTTPDetails(herr)
+ a.status = status.New(codes.Unknown, herr.Message)
default:
return false
}
diff --git a/vendor/github.com/googleapis/gax-go/v2/internal/version.go b/vendor/github.com/googleapis/gax-go/v2/internal/version.go
index 0ba5da1..936873e 100644
--- a/vendor/github.com/googleapis/gax-go/v2/internal/version.go
+++ b/vendor/github.com/googleapis/gax-go/v2/internal/version.go
@@ -30,4 +30,4 @@
package internal
// Version is the current tagged release of the library.
-const Version = "2.7.0"
+const Version = "2.7.1"