<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:59:38 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-3449] CSFLE - incorrect binary subtype for UUID on data encryption keys</title>
                <link>https://jira.mongodb.org/browse/JAVA-3449</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;The createKey() method called to create a data encryption key in client-side field level encryption inserts a document containing details about the key into the keyVault collection. The _id field is assigned a UUID and is referenced by the JSON Schema that provides field encryption instructions.&lt;/p&gt;

&lt;p&gt;According to the CSFLE driver spec, this UUID should be binary type 4:&lt;/p&gt;

&lt;p&gt;&#160;&lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#keyid&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#keyid&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, upon retrieval (when querying using binary type 4 UUID), it is displayed as type 3 (legacy UUID, deprecated type).&lt;/p&gt;

&lt;p&gt;E.g.&lt;br/&gt;
Bson query = Filters.eq(&quot;_id&quot;, new Binary((byte) 4, Base64.getDecoder().decode(base64KeyId)));&lt;br/&gt;
returns a document:&lt;/p&gt;
{&quot;_id&quot;: \{&quot;$binary&quot;: &quot;+EibT2Og09oc/SPTqXxOvw==&quot;, &quot;$type&quot;: &quot;03&quot;}
&lt;p&gt;, &quot;...}&lt;br/&gt;
&#160;&lt;/p&gt;

&lt;p&gt;While this does not appear to impact the functionality when using the Java (3.11.0 sync) driver, it may be due to and cause issues for other drivers.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;To reproduce, this code can be used to create the data key:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/master/driver-sync/src/examples/tour/ClientSideEncryptionSimpleTour.java&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/blob/master/driver-sync/src/examples/tour/ClientSideEncryptionSimpleTour.java&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the query will look something like this (where base64KeyId is the UUID encoded in base64 which is returned from the createKey() method call):&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;Bson query = Filters.eq(&quot;&lt;em&gt;id&quot;, &lt;b&gt;new&lt;/b&gt; Binary((&lt;b&gt;byte&lt;/b&gt;) 4, Base64._getDecoder&lt;/em&gt;().decode(base64KeyId)));&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;Document doc = collection&lt;/tt&gt;&lt;tt&gt;.find(query)&lt;/tt&gt;&lt;tt&gt;.first();&lt;/tt&gt;&lt;tt&gt;&#160;&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;System.&lt;b&gt;&lt;em&gt;out&lt;/em&gt;&lt;/b&gt;.println(doc.toJson());&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Note/Question: the output also appears to be extended json v1, but the documentation mentions the Java driver should be using v2. Perhaps the default behavior of Document.toJson() is to print v1 even if the underlying representation is v2? &lt;a href=&quot;https://docs.mongodb.com/manual/reference/mongodb-extended-json/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://docs.mongodb.com/manual/reference/mongodb-extended-json/&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="939860">JAVA-3449</key>
            <summary>CSFLE - incorrect binary subtype for UUID on data encryption keys</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13202">Works as Designed</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="chris.cho@mongodb.com">Christopher Cho</reporter>
                        <labels>
                    </labels>
                <created>Wed, 25 Sep 2019 16:00:40 +0000</created>
                <updated>Fri, 27 Oct 2023 13:21:03 +0000</updated>
                            <resolved>Wed, 25 Sep 2019 17:53:19 +0000</resolved>
                                                                    <component>Client Side Encryption</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="2433280" author="chris.cho" created="Wed, 25 Sep 2019 18:07:23 +0000"  >&lt;p&gt;Thanks for the clarification.&lt;/p&gt;</comment>
                            <comment id="2433249" author="jeff.yemin" created="Wed, 25 Sep 2019 17:53:19 +0000"  >&lt;p&gt;The data key is being saved correctly.  The problem is with the way the driver decodes and encodes UUIDs when using the Document Codec.  &lt;/p&gt;

&lt;p&gt;You can see that it&apos;s saved correctly if you instead retrieve the document as a &lt;tt&gt;BsonDocument&lt;/tt&gt;:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;        BsonDocument keyDocument = mongoClient.getDatabase(&quot;admin&quot;)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;                .getCollection(&quot;datakeys&quot;)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;                .withDocumentClass(BsonDocument.class)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;                .find().first();&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;        System.out.println(keyDocument.get(&quot;_id&quot;).asBinary().getType());&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;It will print &quot;4&quot;.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                                        </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hvh0rj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>