4 ms·
This seems like something we're not supposed to do... why not just use tls or ssh?
by jessaustin 10y ago
This seems like something we're not supposed to do... why not just use tls or ssh?
- vertex-four 10y agoTLS client authentication (which I think is what you're getting at) is a pain in the ass to implement clients for properly - OpenSSL is dreadful to use, and for many HTTP client libraries you'll need to use it (or a very thin wrapper) to set X.509 client certs, if you even can. On the other hand, there's decent libraries and plenty of information on how to generate and verify an HMAC, and avoid replay attacks.
- jessaustin 10y agoNo that's not what I'm getting at. I'm saying the design of secure protocols is best left for smart people. Every time you post on HN, you're using cookie auth, but you don't have to worry about replay attacks because everything runs inside TLS. Any environment that has HMAC libraries also has the libraries one would need to do the right thing.
- nitrogen 10y agoHMAC is useful for expiring, limited-use tokens without having to store every single token, just the base key. It's used by CloudFront, for example.
- jessaustin 10y agoOh definitely, just pointing out that TLS client certs are used only rarely.
- pjscott 10y agoAs far as I can tell, that's the usual way to do it these days: make the API HTTPS-only, and stick the auth token in each request. Using secure connections isn't expensive anymore.
- BillinghamJ 10y agoIndeed, hence my comment about it being non-trivial. Regardless, there are many possible cases where you wouldn't be able to use TLS for whatever reason, though it's very rare.