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

ClientSideEncryptionExplicitEncryptionAndDecryptionTour throws exception on decrypt

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Unknown Unknown
    • None
    • None
    • Docs Examples
    • None
    • Fully Compatible
    • 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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: