Skip to content

Commit 01a774c

Browse files
fix private key auth (#2170)
1 parent ee0f6af commit 01a774c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pkg/provider/provider.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,11 @@ func ConfigureProvider(s *schema.ResourceData) (interface{}, error) {
707707
privateKeyPath := s.Get("private_key_path").(string)
708708
privateKey := s.Get("private_key").(string)
709709
privateKeyPassphrase := s.Get("private_key_passphrase").(string)
710-
if v, err := getPrivateKey(privateKeyPath, privateKey, privateKeyPassphrase); err != nil && v != nil {
710+
v, err := getPrivateKey(privateKeyPath, privateKey, privateKeyPassphrase)
711+
if err != nil {
712+
return nil, fmt.Errorf("could not retrieve private key: %w", err)
713+
}
714+
if v != nil {
711715
config.PrivateKey = v
712716
}
713717

pkg/provider/provider_helpers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ func mergeSchemas(schemaCollections ...map[string]*schema.Resource) map[string]*
3030
}
3131

3232
func getPrivateKey(privateKeyPath, privateKeyString, privateKeyPassphrase string) (*rsa.PrivateKey, error) {
33+
if privateKeyPath == "" && privateKeyString == "" {
34+
return nil, nil
35+
}
3336
privateKeyBytes := []byte(privateKeyString)
3437
var err error
3538
if len(privateKeyBytes) == 0 && privateKeyPath != "" {

0 commit comments

Comments
 (0)