From 36c4f244a9a9b2f270ee3a792afb9e15f86dcb12 Mon Sep 17 00:00:00 2001 From: Gaukas Wang Date: Fri, 3 Mar 2023 12:31:36 -0700 Subject: [PATCH] fix: preshared key fingerprinter test updated fingerprinter test to test with PreSharedKey extension --- u_common.go | 3 ++- u_fingerprinter_test.go | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/u_common.go b/u_common.go index 21da7a6..fd21556 100644 --- a/u_common.go +++ b/u_common.go @@ -200,7 +200,8 @@ func (chs *ClientHelloSpec) ReadTLSExtensions(b []byte, keepPSK, allowBluntMimic } if extension == extensionPreSharedKey && !keepPSK { - continue // skip PSK, this will result in fingerprint change!!!! + return fmt.Errorf("PSK extension is not allowed unless keepPSK is set") + // continue // skip PSK, this will result in fingerprint change!!!! } extWriter := ExtensionIDToExtension(extension) diff --git a/u_fingerprinter_test.go b/u_fingerprinter_test.go index 0f761aa..90f8b07 100644 --- a/u_fingerprinter_test.go +++ b/u_fingerprinter_test.go @@ -514,10 +514,8 @@ func TestUTLSFingerprintClientHelloKeepPSK(t *testing.T) { } for _, ext := range generatedSpec.Extensions { - if genericExtension, ok := (ext).(*GenericExtension); ok { - if genericExtension.Id == extensionPreSharedKey { - return - } + if _, ok := (ext).(*PreSharedKeyExtension); ok { + return } } t.Errorf("generated ClientHelloSpec with KeepPSK does not include preshared key extension")