Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-4809

ClientSideEncryptionExplicitEncryptionAndDecryptionTour throws exception on decrypt

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Docs Examples
    • None
    • Fully Compatible
    • Needed

      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.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: