@@ -79,7 +79,8 @@ func TestSoftHSMConcurrentSignRequests(t *testing.T) {
7979 RunServer : true ,
8080 }); err != nil {
8181 cancel ()
82- t .Fatalf ("Failed to start signing server: %v" , err )
82+ t .Errorf ("Failed to start signing server: %v" , err )
83+ return
8384 }
8485 }()
8586
@@ -148,10 +149,15 @@ outer:
148149 if hsmPublicKeyFile == "" {
149150 log .Println ("HSM_PUBLIC_KEY_FILE environment variable is not set, skipping public key verification" )
150151 } else {
151- if block == nil || block .Type != "PUBLIC KEY" {
152+ hsmPublicKeyData , err := os .ReadFile (hsmPublicKeyFile )
153+ if err != nil {
154+ log .Fatalf ("Failed to read public key file %s: %v" , hsmPublicKeyFile , err )
155+ }
156+ publicKeyBlock , _ := pem .Decode (hsmPublicKeyData )
157+ if publicKeyBlock == nil || publicKeyBlock .Type != "PUBLIC KEY" {
152158 log .Fatal ("Failed to parse PEM block for public key" )
153159 }
154- pub , err := x509 .ParsePKIXPublicKey (block .Bytes )
160+ pub , err := x509 .ParsePKIXPublicKey (publicKeyBlock .Bytes )
155161 if err != nil {
156162 log .Fatalf ("Failed to parse public key: %v" , err )
157163 }
@@ -165,6 +171,8 @@ outer:
165171 }
166172 if err := rsa .VerifyPSS (rsaPubKey , crypto .SHA256 , rawDigest , block .Bytes , nil ); err != nil {
167173 log .Fatalf ("Signature verification failed: %v" , err )
174+ } else {
175+ log .Printf ("Signature verification succeeded for request %d" , index )
168176 }
169177 }
170178
0 commit comments