[JAVA-4809] ClientSideEncryptionExplicitEncryptionAndDecryptionTour throws exception on decrypt Created: 11/Nov/22  Updated: 16/Nov/22  Resolved: 16/Nov/22

Status: Closed
Project: Java Driver
Component/s: Docs Examples
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Unknown
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Documentation Changes: Needed

 Description   

Exception in thread "main" com.mongodb.MongoClientException: Exception in encryption library: decryption expected BSON binary subtype 6, got 0
	at com.mongodb.client.internal.Crypt.wrapInClientException(Crypt.java:370)
	at com.mongodb.client.internal.Crypt.decryptExplicitly(Crypt.java:230)
	at com.mongodb.client.internal.ClientEncryptionImpl.decrypt(ClientEncryptionImpl.java:93)
	at tour.ClientSideEncryptionExplicitEncryptionAndDecryptionTour.main(ClientSideEncryptionExplicitEncryptionAndDecryptionTour.java:105)
Caused by: com.mongodb.crypt.capi.MongoCryptException: decryption expected BSON binary subtype 6, got 0
	at com.mongodb.crypt.capi.MongoCryptContextImpl.throwExceptionFromStatus(MongoCryptContextImpl.java:156)
	at com.mongodb.crypt.capi.MongoCryptImpl.configure(MongoCryptImpl.java:350)
	at com.mongodb.crypt.capi.MongoCryptImpl.createExplicitDecryptionContext(MongoCryptImpl.java:299)
	at com.mongodb.client.internal.Crypt.decryptExplicitly(Crypt.java:227)
	... 2 more

It's due to the fact that when the BsonBinary instance is constructed from the Binary instance, the subtype is not preserved, so it defaults to 0.



 Comments   
Comment by Githook User [ 16/Nov/22 ]

Author:

{'name': 'Jeff Yemin', 'email': 'jeff.yemin@mongodb.com', 'username': 'jyemin'}

Message: Fix explicit decryption code in tour (#1047)

JAVA-4809
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/4317400a1029d4d74403929e18a3eefd7b321470

Generated at Thu Feb 08 09:03:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.