Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private Key is null in CertificateBundle using of(String serialNumber, String certificate, String issuingCaCertificate, String privateKey) #857

Closed
JackSilk opened this issue Feb 26, 2024 · 2 comments
Labels
type: regression A regression from a previous release
Milestone

Comments

@JackSilk
Copy link

JackSilk commented Feb 26, 2024

Hello,

I'm trying to update from Spring Vault 3.0.2 to 3.1.0 (through spring-cloud-starter-vault-config) and I'm having an issue where, having created an instance of the CertificateBundle, I get null when I try to get the private key back.

Here's a simple test case to illustrate.

@Test
  void shouldNotThrowNullPointerExceptionWhenGettingPrivateKey() {
    var serialNumber = "aserialnumber";
    var certificate = "certificate";
    var caCertificate = "caCertificate";
    var privateKey = "aprivatekey";
    
 var certificateBundle =
        CertificateBundle.of(serialNumber, certificate, caCertificate, privateKey);
    Assertions.assertThat(certificateBundle.getPrivateKey()).isNotNull();
  }

I had a look at the code and it seems to me that the order of arguments is transposed on this line

Collections.singletonList(issuingCaCertificate), null, privateKey, null);

That is, it's passing null as the privateKey argument and passing the intended private key to the privateKeyType argument.

Does that look/sound like it makes sense? Thanks for your assistance.

@mp911de mp911de added the type: regression A regression from a previous release label Feb 27, 2024
@mp911de
Copy link
Member

mp911de commented Feb 27, 2024

This is a regression from an earlier change. As a workaround, please use a different factory method until this is fixed.

@mp911de mp911de added this to the 3.1.2 milestone Jun 6, 2024
@mp911de mp911de changed the title Private Key is null in CertificateBundle Private Key is null in CertificateBundle using of(String serialNumber, String certificate, String issuingCaCertificate, String privateKey) Jun 6, 2024
@mp911de mp911de closed this as completed in 9fd2e60 Jun 6, 2024
@mp911de
Copy link
Member

mp911de commented Jun 6, 2024

That's fixed now.

mp911de added a commit that referenced this issue Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

2 participants