go-piv / piv-go

Keys and certificates for YubiKeys, written in Go
Apache License 2.0
366 stars 65 forks source link

Add an API to enable APDU debugging. #134

Closed areese closed 9 months ago

areese commented 9 months ago

This PR adds a debug flag to the sc context to dump the contents of every APDU to the console.

This is very useful to see what APDU's are being sent to a card.

ericchiang commented 9 months ago

Hey, thanks for the PR

Go packages generally don't implement their own debug printing, since your main package is going to be opinionated about that. What if stdout is used by the executable for some inter-process communication? What if the program uses a custom log package or structured logging (pkg.go.dev/log/slog)?

Happy to add a trace-like API if this is a common use case (https://pkg.go.dev/net/http/httptrace). But I don't think this is the correct API.

areese commented 9 months ago

@ericchiang that's fine, I can do it a different way. :)

areese commented 9 months ago

This is only used when you really need to know what's wrong.

areese commented 9 months ago

Closing this in favor of an httptrace like api that I'll write shortly.