deps: Update github.com/joyent/triton-go/authentication (#13255)
This commit allows private key material to be used with the Triton provider, which is necessary for running acceptance tests in the HashiCorp CI environment.
This commit is contained in:
parent
d7a339eb46
commit
50fb9aecbd
|
@ -7,10 +7,12 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/errwrap"
|
"github.com/hashicorp/errwrap"
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PrivateKeySigner struct {
|
type PrivateKeySigner struct {
|
||||||
|
@ -27,23 +29,23 @@ func NewPrivateKeySigner(keyFingerprint string, privateKeyMaterial []byte, accou
|
||||||
|
|
||||||
block, _ := pem.Decode(privateKeyMaterial)
|
block, _ := pem.Decode(privateKeyMaterial)
|
||||||
if block == nil {
|
if block == nil {
|
||||||
return nil, fmt.Errorf("Error PEM-decoding private key material: nil block received")
|
return nil, errors.New("Error PEM-decoding private key material: nil block received")
|
||||||
}
|
}
|
||||||
|
|
||||||
rsakey, err := x509.ParsePKCS1PrivateKey(block.Bytes)
|
rsakey, err := x509.ParsePKCS1PrivateKey(block.Bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errwrap.Wrapf("Error parsing private key: %s", err)
|
return nil, errwrap.Wrapf("Error parsing private key: {{err}}", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sshPublicKey, err := ssh.NewPublicKey(rsakey.Public())
|
sshPublicKey, err := ssh.NewPublicKey(rsakey.Public())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errwrap.Wrapf("Error parsing SSH key from private key: %s", err)
|
return nil, errwrap.Wrapf("Error parsing SSH key from private key: {{err}}", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
matchKeyFingerprint := formatPublicKeyFingerprint(sshPublicKey, false)
|
matchKeyFingerprint := formatPublicKeyFingerprint(sshPublicKey, false)
|
||||||
displayKeyFingerprint := formatPublicKeyFingerprint(sshPublicKey, true)
|
displayKeyFingerprint := formatPublicKeyFingerprint(sshPublicKey, true)
|
||||||
if matchKeyFingerprint != keyFingerprintMD5 {
|
if matchKeyFingerprint != keyFingerprintMD5 {
|
||||||
return nil, fmt.Errorf("Private key file does not match public key fingerprint")
|
return nil, errors.New("Private key file does not match public key fingerprint")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &PrivateKeySigner{
|
return &PrivateKeySigner{
|
||||||
|
@ -69,5 +71,6 @@ func (s *PrivateKeySigner) Sign(dateHeader string) (string, error) {
|
||||||
}
|
}
|
||||||
signedBase64 := base64.StdEncoding.EncodeToString(signed)
|
signedBase64 := base64.StdEncoding.EncodeToString(signed)
|
||||||
|
|
||||||
return fmt.Sprintf(authorizationHeaderFormat, s.formattedKeyFingerprint, "rsa-sha1", headerName, signedBase64), nil
|
keyID := fmt.Sprintf("/%s/keys/%s", s.accountName, s.formattedKeyFingerprint)
|
||||||
|
return fmt.Sprintf(authorizationHeaderFormat, keyID, "rsa-sha1", headerName, signedBase64), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -2296,14 +2296,14 @@
|
||||||
{
|
{
|
||||||
"checksumSHA1": "fue8Al8kqw/Q6VFPsNzoky7NIgo=",
|
"checksumSHA1": "fue8Al8kqw/Q6VFPsNzoky7NIgo=",
|
||||||
"path": "github.com/joyent/triton-go",
|
"path": "github.com/joyent/triton-go",
|
||||||
"revision": "ed036af6d128e3c1ef76e92218810d3b298d1407",
|
"revision": "66b31a94af28a65e902423879a2820ea34b773fb",
|
||||||
"revisionTime": "2017-03-30T22:02:44Z"
|
"revisionTime": "2017-03-31T18:12:29Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "7sIV9LK625xVO9WsV1gaLQgfBeY=",
|
"checksumSHA1": "QzUqkCSn/ZHyIK346xb9V6EBw9U=",
|
||||||
"path": "github.com/joyent/triton-go/authentication",
|
"path": "github.com/joyent/triton-go/authentication",
|
||||||
"revision": "ed036af6d128e3c1ef76e92218810d3b298d1407",
|
"revision": "66b31a94af28a65e902423879a2820ea34b773fb",
|
||||||
"revisionTime": "2017-03-30T22:02:44Z"
|
"revisionTime": "2017-03-31T18:12:29Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "YhQcOsGx8r2S/jkJ0Qt4cZ5BLCU=",
|
"checksumSHA1": "YhQcOsGx8r2S/jkJ0Qt4cZ5BLCU=",
|
||||||
|
|
Loading…
Reference in New Issue