Skip to content

Commit

Permalink
add testfile tls/testcert.pem tls/testkey.pem
Browse files Browse the repository at this point in the history
  • Loading branch information
wangtiga committed Nov 11, 2023
1 parent 187e52f commit 03597fd
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
2 changes: 0 additions & 2 deletions internal/certigo/lib/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions internal/certigo/lib/certs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
24 changes: 24 additions & 0 deletions internal/certigo/lib/tls/testcert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-----BEGIN CERTIFICATE-----
MIIEDzCCAvegAwIBAgIUb9rMtZakmrPUSehrVFATTotK2JAw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BCbOuEASfLT05mq16aIh834gIVB3upYFsBkB5bBpRg
LnNTYHSnnpB5k/jikLapgJk/cyRXPQkxCdtH4TwB813iOvou/BSrIIvUYh0vFmGW
cLe3abB+zCg8gwbOf4pvLGp37ogtTQo2gkcPI2CrKEnpxs4J5AabkCLuk+2XyClP
9ow3eZAqTUsMOsKbHLGMBOnMthRbpN8UWGWTm8yYo296Kt1Gs1PbBw+xHC84KLsq
unwlChN+nOKOW4sPIMb9rjkPGMgOgu4rQmqeoGf295fbFIs=
-----END CERTIFICATE-----
28 changes: 28 additions & 0 deletions internal/certigo/lib/tls/testkey.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQClgI4KyVvvN3QG
GzfGkKVUsW26sX4aJGr57pS7ZKOZdEwZ2SgCUTih2BChfOMBGDALnarH1JBKugMR
IM/aG9zKqchTkSztWsrIMOLszs5qfw/eXXG2OPbKEH8UCgNfVLzEq/BEQXaFC42k
e6DQp39o9nDZGU/8gTevBXEyy6Bh/gh/imaL1Ic47MHsPUOdZfVqtkMRDRa3imsU
BJMAPIvocXdlaFSKw0S9Yu1DEDmH44D2lVjz4pb7h/v3srh7lVvOM4qh8yzO/GTB
wVyQd4OB9Yq49W3z7eeC+5Kspr9aWmGjlKUh6gXCBPPjZbzkp1ti3kag3QDd7XKu
zSL7GEbxAgMBAAECggEAEh4xLpgdkuIQtwxqvjeeideEqi/9HJKJDYRjTuJ1EHsN
S7UcrqhCmWEkbPFVjoyd0d+4TvkDtNKJPGpJpthvAta0YgWeE/vhACpt5Tu8mCcB
zzeOl8LDrZpBtyljdh+6LJOgEXDTLzx1DKEmGUGE7rIv52xgd8WTmXrwif2FuMRf
7o3hJe7KxUZ3ZtOPzHvyy+L2mghrqkMp0kEIb7XfoCYPHWHHElvunZBndQUTC6g5
MIbMfB5nBilniZtk3YxNIeMgDxj2iOX6SPYUiT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