diff --git a/internal/handshake/crypto_setup.go b/internal/handshake/crypto_setup.go index 2c90089e..bf510653 100644 --- a/internal/handshake/crypto_setup.go +++ b/internal/handshake/crypto_setup.go @@ -462,7 +462,7 @@ func (h *cryptoSetup) WriteRecord(p []byte) (int, error) { } func (h *cryptoSetup) SendAlert(alert uint8) { - h.alertChan <- qerr.CryptoError(alert) + h.alertChan <- qerr.CryptoError(alert, "") } func (h *cryptoSetup) GetSealer() (protocol.EncryptionLevel, Sealer) { diff --git a/internal/qerr/quic_error.go b/internal/qerr/quic_error.go index ae1cd76e..f4eb476d 100644 --- a/internal/qerr/quic_error.go +++ b/internal/qerr/quic_error.go @@ -31,9 +31,10 @@ func TimeoutError(errorMessage string) *QuicError { } // CryptoError create a new QuicError instance for a crypto error -func CryptoError(tlsAlert uint8) *QuicError { +func CryptoError(tlsAlert uint8, errorMessage string) *QuicError { return &QuicError{ - ErrorCode: 0x100 + ErrorCode(tlsAlert), + ErrorCode: 0x100 + ErrorCode(tlsAlert), + ErrorMessage: errorMessage, } } diff --git a/internal/qerr/quic_error_test.go b/internal/qerr/quic_error_test.go index 4cb1404a..7059c841 100644 --- a/internal/qerr/quic_error_test.go +++ b/internal/qerr/quic_error_test.go @@ -25,8 +25,13 @@ var _ = Describe("QUIC Transport Errors", func() { Expect(err.Error()).To(Equal("NO_ERROR: foobar")) }) - It("has a string representation for crypto errors", func() { - err := CryptoError(42) + It("has a string representation for crypto errors with a message", func() { + err := CryptoError(42, "foobar") + Expect(err.Error()).To(Equal("CRYPTO_ERROR: foobar")) + }) + + It("has a string representation for crypto errors without a message", func() { + err := CryptoError(42, "") Expect(err.Error()).To(Equal("CRYPTO_ERROR: tls: bad certificate")) })