55 "context"
66 "crypto/tls"
77 "crypto/x509"
8+ "encoding/pem"
89 "net"
910 "os"
1011 "path/filepath"
@@ -618,6 +619,24 @@ func TestSecurityConfigWatch(t *testing.T) {
618619 require .NoError (t , ca .RenewTLSConfigNow (tc .Context , secConfig , tc .ConnBroker , tc .Paths .RootCA ))
619620}
620621
622+ func printCert (t * testing.T , pemData []byte ) {
623+ t .Helper ()
624+
625+ block , _ := pem .Decode (pemData )
626+ cert , err := x509 .ParseCertificate (block .Bytes )
627+ if err != nil {
628+ t .Error (err )
629+ }
630+
631+ cert .RawSubject = nil
632+ cert .Raw = nil
633+ cert .RawIssuer = nil
634+ cert .RawSubjectPublicKeyInfo = nil
635+ cert .RawTBSCertificate = nil
636+ cert .Signature = nil
637+ t .Logf ("%+v" , cert )
638+ }
639+
621640// If we get an unknown authority error when trying to renew the TLS certificate, attempt to download the
622641// root certificate. If it validates against the current TLS credentials, it will be used to download
623642// new ones, (only if the new certificate indicates that it's a worker, though).
@@ -633,6 +652,8 @@ func TestRenewTLSConfigUpdatesRootOnUnknownAuthError(t *testing.T) {
633652 for i := 0 ; i < 3 ; i ++ {
634653 certs [i ], keys [i ], err = cautils .CreateRootCertAndKey ("CA" + strconv .Itoa (i ))
635654 require .NoError (t , err )
655+ t .Log ("CA" + strconv .Itoa (i ), ":\n " , string (certs [i ]))
656+ printCert (t , certs [i ])
636657 switch i {
637658 case 0 :
638659 crossSigneds [i ] = nil
@@ -641,6 +662,8 @@ func TestRenewTLSConfigUpdatesRootOnUnknownAuthError(t *testing.T) {
641662 default :
642663 crossSigneds [i ], err = cas [i - 1 ].CrossSignCACertificate (certs [i ])
643664 require .NoError (t , err )
665+ t .Log ("Intermediate" + strconv .Itoa (i ), ":\n " , string (crossSigneds [i ]))
666+ printCert (t , crossSigneds [i ])
644667 cas [i ], err = ca .NewRootCA (certs [i - 1 ], certs [i ], keys [i ], ca .DefaultNodeCertExpiration , crossSigneds [i ])
645668 require .NoError (t , err )
646669 }
0 commit comments