Closed Bug 956189 Opened 11 years ago Closed 7 years ago

Firefox on windows use application/octet-stream in form-data when I try to upload a validate .cer file to my server

Categories

(Firefox :: File Handling, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: enlian1988, Unassigned)

References

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 Steps to reproduce: I tried to upload a .crt file using form-data from my UI to send to my server which accepts "application/x-x509-ca-cert" content-type. Actual results: And server always return 415. In the web console I saw "application/octet-stream" was used in the form data payload. Expected results: The browser should use "application/x-x509-ca-cert" as a content-type for that file. Tested on Ubuntu chrome and firefox and windows chrome, all work, except firefox in windows.
Severity: normal → blocker
Do you have an entry in your profile's mimeTypes.rdf that maps that file extension to that content type?
Severity: blocker → normal
Flags: needinfo?(enlian1988)
Hi Boris, First thanks for your quick respond. "mimeTypes.rdf" contains "Action to perform when downloading certain types of files. Can be deleted to reset download actions."(what I got from http://kb.mozillazine.org/Profile_folder_-_Firefox) In my situation, I have a UI webpage from where user can choose a certificate file and upload to my server using http content-type: multipart/form-data. Here is the payload I saw on a firefox on ubuntu when I upload a xxx.pem file Content-Type: multipart/form-data; boundary=---------------------------18259983374115114541426671916 Content-Length: 5557 -----------------------------18259983374115114541426671916 Content-Disposition: form-data; name="cert"; filename="test_cacert.pem" Content-Type: application/x-x509-ca-cert And when I use a ".crt" file the Content-Type becomes : "application/pkix-cert", which is also good. But on windows7 firefox, no matter I use .crt or .cer file, the browser cannot get the right type of the file, it always use application/octet-stream. 1. part of payload when I use ".crt" file : -----------------------------108921559915207 Content-Disposition: form-data; name="cert"; filename="test_cacert - Copy (1).crt" Content-Type: application/octet-stream 2. part of payload when I use ".crt" file : -----------------------------266961966619630 Content-Disposition: form-data; name="cert"; filename="test_cacert - Copy (1).crt" Content-Type: application/octet-stream But when I use chrome on windows to do exactly the same thing, the Content-Type was correctly set to "application/x-x509-ca-cert" I searched a lot online but didnt find a solution, So I think this may be a bug. Thanks.
> "mimeTypes.rdf" contains "Action to perform when downloading certain types of files. It also contains type-to-extension and extension-to-type mappings, which are used when determining the MIME type to use for a file with the given extension. Hence me asking whether yours in particular contains such mappings for the ".cer" and ".crt" extensions.
What you said makes sense. I checked the "mimeTypes.rdf" in my windows and Ubuntu machine. They both only contain application/pdf mappings. But the fact is Firefox in ubuntu will use "application/x-x509-ca-cert" for .cer files, but Firefox in Windows just use "application/octet-stream" instead.
Flags: needinfo?(enlian1988)
Plz correct me if I'm wrong. I guess Firefox has a default built-in file type <-> mimetype mapping which will do the right job for commonly accepted file formats like jpeg, png, pdf... And also it provides "mimeTypes.rdf" to give user the freedom to set additional mappings for some not commonly used 3rd party or user own defined file formats, right? And .cer, .crt and .pem are all publicly accepeted file types for certificates, and they should be supported without extra configuration, right?
Firefox does have such a mapping. We also use mimeTypes.rdf and the OS-provided MIME mappings. We could certainly add these extensions to our default mappings... Does your Windows installation not have extension-to-MIME-type mappings in the registry for these extensions?
Component: General → File Handling
I do have .cer and .crt mapped as application/x-x509-ca-cert in my registry. That's why I think it's weird.
They are in \HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ But seems like Firefox didn't use them.
We look under \HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.cer and \HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.crt to get the MIME mappings, as far as I can tell. Could you please do a log as described at https://developer.mozilla.org/en-US/docs/Mozilla/Debugging/HTTP_logging but set NSPR_LOG_MODULES=HelperAppService:5 and attach the result here?
Product: Core → Firefox
Version: 26 Branch → unspecified
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Depends on: 1352348
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.