From 03597fd3e851b408d2105cda4707aea5a24eb2be Mon Sep 17 00:00:00 2001 From: wangtiga Date: Sat, 11 Nov 2023 21:38:28 +0800 Subject: [PATCH] add testfile tls/testcert.pem tls/testkey.pem --- internal/certigo/lib/certs.go | 2 -- internal/certigo/lib/certs_test.go | 1 + internal/certigo/lib/tls/testcert.pem | 24 +++++++++++++++++++++++ internal/certigo/lib/tls/testkey.pem | 28 +++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 internal/certigo/lib/tls/testcert.pem create mode 100644 internal/certigo/lib/tls/testkey.pem diff --git a/internal/certigo/lib/certs.go b/internal/certigo/lib/certs.go index 81d47ace..67320592 100644 --- a/internal/certigo/lib/certs.go +++ b/internal/certigo/lib/certs.go @@ -162,7 +162,6 @@ func GuessFormatForFile(filename string, format CertificateKeyFormat) (Certifica // Heuristics for guessing -- best effort. magic := binary.BigEndian.Uint32(data) - fmt.Printf(" magic 0x%0x\n", magic) if magic == 0xCECECECE || magic == 0xFEEDFEED { // JCEKS/JKS files always start with this prefix return CertKeyFormatJCEKS, nil @@ -355,7 +354,6 @@ func readCertsFromStream(reader io.Reader, filename string, format CertificateKe x509Certs, err0 := x509.ParseCertificates(data) if err0 == nil { for _, cert := range x509Certs { - fmt.Printf("cert cn: %v\n", cert.Issuer.CommonName) err := callback(encodeX509ToPEM(cert, headers), format) if err != nil { return err diff --git a/internal/certigo/lib/certs_test.go b/internal/certigo/lib/certs_test.go index d0f694f6..c7d32ff1 100644 --- a/internal/certigo/lib/certs_test.go +++ b/internal/certigo/lib/certs_test.go @@ -13,6 +13,7 @@ func TestClientTLSConfig(t *testing.T) { testTLSConfig(t, false, "tls/ca.crt", pemfmt, "tls/client.pfx", pfxfmt, "tls/client.key", pemfmt, "") testTLSConfig(t, false, "tls/ca.crt", pemfmt, "tls/client_pass.pfx", pfxfmt, "", pemfmt, "pfxpassword") testTLSConfig(t, false, "tls/ca.der", derfmt, "tls/client.pfx", pfxfmt, "", pemfmt, "") + testTLSConfig(t, false, "tls/ca.crt", pemfmt, "tls/testcert.pem", pemfmt, "tls/testkey.pem", pemfmt, "") } func testTLSConfig( diff --git a/internal/certigo/lib/tls/testcert.pem b/internal/certigo/lib/tls/testcert.pem new file mode 100644 index 00000000..1804f116 --- /dev/null +++ b/internal/certigo/lib/tls/testcert.pem @@ -0,0 +1,24 @@ +-----BEGIN CERTIFICATE----- +MIIEDzCCAvegAwIBAgIUb9rMtZakmrPUSehrVFATTotK2JAwDQYJKoZIhvcNAQEL +BQAwgZYxCzAJBgNVBAYTAlVTMRAwDgYDVQQIDAdHZW9yZ2lhMRAwDgYDVQQHDAdB +dGxhbnRhMRIwEAYDVQQKDAlGdWxsU3RvcnkxFDASBgNVBAsMC0VuZ2luZWVyaW5n +MRMwEQYDVQQDDApTY290dCBCbHVtMSQwIgYJKoZIhvcNAQkBFhVkcmFnb25zaW50 +aEBnbWFpbC5jb20wHhcNMjMxMTAyMTYzMDI2WhcNMjQxMTAxMTYzMDI2WjCBljEL +MAkGA1UEBhMCVVMxEDAOBgNVBAgMB0dlb3JnaWExEDAOBgNVBAcMB0F0bGFudGEx +EjAQBgNVBAoMCUZ1bGxTdG9yeTEUMBIGA1UECwwLRW5naW5lZXJpbmcxEzARBgNV +BAMMClNjb3R0IEJsdW0xJDAiBgkqhkiG9w0BCQEWFWRyYWdvbnNpbnRoQGdtYWls +LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKWAjgrJW+83dAYb +N8aQpVSxbbqxfhokavnulLtko5l0TBnZKAJROKHYEKF84wEYMAudqsfUkEq6AxEg +z9ob3MqpyFORLO1aysgw4uzOzmp/D95dcbY49soQfxQKA19UvMSr8ERBdoULjaR7 +oNCnf2j2cNkZT/yBN68FcTLLoGH+CH+KZovUhzjswew9Q51l9Wq2QxENFreKaxQE +kwA8i+hxd2VoVIrDRL1i7UMQOYfjgPaVWPPilvuH+/eyuHuVW84ziqHzLM78ZMHB +XJB3g4H1irj1bfPt54L7kqymv1paYaOUpSHqBcIE8+NlvOSnW2LeRqDdAN3tcq7N +IvsYRvECAwEAAaNTMFEwHQYDVR0OBBYEFEtQbQRGQjJJgKwYhIHbnCihExdxMB8G +A1UdIwQYMBaAFEtQbQRGQjJJgKwYhIHbnCihExdxMA8GA1UdEwEB/wQFMAMBAf8w +DQYJKoZIhvcNAQELBQADggEBAIw/P+VNIv75FghOYuEiCIGf63A1vjoMmNOJ7xI2 +t9dmW54/1MHqC3KlQYyOzTBCbOuEASfLT05mq16aIh834gIVB3upYFsBkB5bBpRg +LnNTYHSnnpB5k/jikLapgJk/cyRXPQkxCdtH4TwB813iOvou/BSrIIvUYh0vFmGW +cLe3abB+zCg8gwbOf4pvLGp37ogtTQo2gkcPI2CrKEnpxs4J5AabkCLuk+2XyClP +9ow3eZAqTUsMOsKbHLGMBOnMthRbpN8UWGWTm8yYo296Kt1Gs1PbBw+xHC84KLsq +unwlChN+nOKOW4sPIMb9rjkPGMgOgu4rQmqeoGf295fbFIs= +-----END CERTIFICATE----- diff --git a/internal/certigo/lib/tls/testkey.pem b/internal/certigo/lib/tls/testkey.pem new file mode 100644 index 00000000..b8b7cba3 --- /dev/null +++ b/internal/certigo/lib/tls/testkey.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQClgI4KyVvvN3QG +GzfGkKVUsW26sX4aJGr57pS7ZKOZdEwZ2SgCUTih2BChfOMBGDALnarH1JBKugMR +IM/aG9zKqchTkSztWsrIMOLszs5qfw/eXXG2OPbKEH8UCgNfVLzEq/BEQXaFC42k +e6DQp39o9nDZGU/8gTevBXEyy6Bh/gh/imaL1Ic47MHsPUOdZfVqtkMRDRa3imsU +BJMAPIvocXdlaFSKw0S9Yu1DEDmH44D2lVjz4pb7h/v3srh7lVvOM4qh8yzO/GTB +wVyQd4OB9Yq49W3z7eeC+5Kspr9aWmGjlKUh6gXCBPPjZbz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