Search code examples
c++mongodbdrivermongo-cxx-driver

MD5 support for mongocxx (mongodb c++ driver) with GridFS


Uploading a file to GridFS storage with the c++ driver doesn't create a md5 entry in the files collection. IE:

auto uploadStream = bucket.open_upload_stream( filename );
uploadStream.write( buffer, size );
uploadStream.close();

enter image description here

Using the node.js api (and probably others) instead does it by default, (and you can optionally disable it).

Is it a missing feature or is it hidden somewhere I could not see? There's no mention of it in any of the docs:

Current mongocxx documentation 3.4.0, latest at the time of writing mongocxx 3.4.0

PS: I know this specific file is smaller than the 16Mb recommended size for GridFS.


Solution

  • Explained in GridFS specification, md5 checksum is deprecated.

    In particular:

    Why are MD5 checksums now deprecated? What should users do instead?

    MD5 is prohibited by FIPS 140-2. Operating systems and libraries operating in FIPS mode do not provide the MD5 algorithm. To avoid a broken GridFS feature on such systems, the use of MD5 with GridFS is deprecated, should not be added to new implementations, and should be removed from existing implementations according to the deprecation policy of individual drivers. Applications that desire a file digest should implement it outside of GridFS and store it with other file metadata.