Skip to content

Commit 25cdfcf

Browse files
committed
Refactor PKCS12 decoding to remove unused CA certificates and simplify error handling
1 parent 6be0204 commit 25cdfcf

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

import-export-cli/utils/encryptionUtils.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,23 +253,16 @@ func getPublicKeyFromPKCS12(keyStorePath string, keyStorePassword []byte, keySto
253253
}
254254

255255
// Decode PKCS12 data using the improved go-pkcs12 library
256-
privateKey, certificate, caCerts, err := pkcs12.DecodeChain(p12Data, string(keyStorePassword))
256+
privateKey, certificate, _, err := pkcs12.DecodeChain(p12Data, string(keyStorePassword))
257257
if err != nil {
258258
// Try with alias-specific password if main password fails
259259
keyPassword, _ := base64.StdEncoding.DecodeString(keyStoreConfig.KeyPassword)
260-
privateKey, certificate, caCerts, err = pkcs12.DecodeChain(p12Data, string(keyPassword))
260+
privateKey, certificate, _, err = pkcs12.DecodeChain(p12Data, string(keyPassword))
261261
if err != nil {
262262
return nil, errors.New("Decoding PKCS12 keystore: " + err.Error())
263263
}
264264
}
265265

266-
// Handle case where we need to find a specific alias
267-
if keyStoreConfig.KeyAlias != "" {
268-
// For PKCS12 with aliases, we might need additional logic
269-
// For now, we'll use the decoded certificate and key
270-
_ = caCerts // Keep for potential future use
271-
}
272-
273266
// Extract RSA private key
274267
var rsaKey *rsa.PrivateKey
275268
switch key := privateKey.(type) {

0 commit comments

Comments
 (0)