Skip to content

Commit

Permalink
Merge pull request #517 from cbosdo/openssl-test-fix
Browse files Browse the repository at this point in the history
Fix TestGetRsaKey running with openssl 1.1
  • Loading branch information
deneb-alpha authored Dec 13, 2024
2 parents f98118c + b68d34f commit 3933b2c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions shared/ssl/ssl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,16 @@ func TestOrderCasChain2(t *testing.T) {
func TestGetRsaKey(t *testing.T) {
key := testutils.ReadFile(t, "testdata/RootCA.key")
actual := string(GetRsaKey(key, "secret"))
if !strings.HasPrefix(actual, "-----BEGIN PRIVATE KEY-----\nMIIEugIBADANBgkqhkiG9w0BAQEFAAS") ||
!strings.HasSuffix(actual, "DKY9SmW6QD+RJwbMc4M=\n-----END PRIVATE KEY-----\n") {

// This is what new openssl would generate
matchingPKCS8 := strings.HasPrefix(actual, "-----BEGIN PRIVATE KEY-----\nMIIEugIBADANBgkqhkiG9w0BAQEFAAS") &&
strings.HasSuffix(actual, "DKY9SmW6QD+RJwbMc4M=\n-----END PRIVATE KEY-----\n")

// This is what older openssl would generate
matchingPKCS1 := strings.HasPrefix(actual, "-----BEGIN RSA PRIVATE KEY-----\nMIIEoAIBAAKCAQEArqQvTR0") &&
strings.HasSuffix(actual, "+3i4RXV4XtWHzmQymPUplukA/kScGzHOD\n-----END RSA PRIVATE KEY-----\n")

if !matchingPKCS1 && !matchingPKCS8 {
t.Errorf("Unexpected generated RSA key: %s", actual)
}
}

0 comments on commit 3933b2c

Please sign in to comment.