cloudflare / gortr

The RPKI-to-Router server used at Cloudflare
https://rpki.cloudflare.com
BSD 3-Clause "New" or "Revised" License
309 stars 39 forks source link

HTTP Client is using an invalid JSON MIME type #62

Open markusju opened 4 years ago

markusju commented 4 years ago

Currently HTTP Requests to a RPKI validation server are made with the header option "Accept: text/json". This is causing issues with APIs of some RPKI servers that are particularly picky about this. For example the /api/objects/validated endpoint of RIPE NCC's rpki-validator-3 does not like "text/json".

"text/json" is not a valid MIME type after all and should be changed to "application/json", possibly avoiding issues with future implementations of RPKI validation servers. (rfc8259)

markusju commented 4 years ago

Well, I just tried patching this, which turned out to be really easy. => Search and replace "text/json" with "application/json".

However, it turns out /api/objects/validated in rpki-validator-3 does not produce data in a proper schema (yet) for gortr. This is another issue which I have raised at this project.

Nevertheless the MIME type is invalid and should most likely be corrected to avoid future incompatibilities.

lspgn commented 4 years ago

I believe the "text/json" was for ripe-rpki-validator 2 but I may be wrong. I can make it available as a CLI argument. I agree on the rest, there is no standard at the moment, and the ASNs format has been changed from "AS65001" to a JSON integer.

Which version of GoRTR are you using? Could you share the JSON file as well?

ties commented 4 years ago

I believe the "text/json" was for ripe-rpki-validator 2 but I may be wrong. I can make it available as a CLI argument. I agree on the rest, there is no standard at the moment, and the ASNs format has been changed from "AS65001" to a JSON integer.

Perhaps standardising this format (and the headers) would be good.

In my eyes a RPKI validation server should not be intolerant of Content-Types however, in practice, if code is implemented in a framework that has dynamic handling of MIME types they will be.

lspgn commented 4 years ago

Made a change to application/json by default but client can configure the Accept header.