Skip to content

Commit 001656e

Browse files
committed
BugFix - replace new line delimeter with new line in private_key for authentication
1 parent 7b03aea commit 001656e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

internal/provider/provider.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,10 @@ func (p ResourceDataConfigProvider) PrivateRSAKey() (key *rsa.PrivateKey, err er
555555
password = privateKeyPassword.(string)
556556
}
557557

558-
if privateKey, hasPrivateKey := p.D.GetOkExists(globalvar.PrivateKeyAttrName); hasPrivateKey {
559-
return oci_common.PrivateKeyFromBytes([]byte(privateKey.(string)), &password)
558+
if privateKey, hasPrivateKey := p.D.GetOk(globalvar.PrivateKeyAttrName); hasPrivateKey {
559+
keyData := privateKey.(string)
560+
keyData = strings.ReplaceAll(keyData, "\\n", "\n") // Ensure \n is replaced by actual newlines
561+
return oci_common.PrivateKeyFromBytesWithPassword([]byte(keyData), []byte(password))
560562
}
561563

562564
if privateKeyPath, hasPrivateKeyPath := p.D.GetOkExists(globalvar.PrivateKeyPathAttrName); hasPrivateKeyPath {

internal/provider/provider_framework.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,8 @@ func (p ConfigProvider) PrivateRSAKey() (key *rsa.PrivateKey, err error) {
562562

563563
privateKey := p.D.privateKey
564564
if privateKey != "" {
565-
return oci_common.PrivateKeyFromBytes([]byte(privateKey), &password)
565+
privateKey := strings.ReplaceAll(p.D.privateKey, "\\n", "\n") // Ensure \n is replaced by actual newlines
566+
return oci_common.PrivateKeyFromBytesWithPassword([]byte(privateKey), []byte(password))
566567
}
567568

568569
privateKeyPath := p.D.privateKeyPath

0 commit comments

Comments
 (0)