Has anyone ran into the following error when using encryption in RavenDB 2.0?
"System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed."
Here is how to recreate the issue:
- Create new Database
- Add Encryption Bundle
- Choose Encryption Algorithm - Rijndael
- Check Encrypt Indexes
- Add the following document via admin site
{
"OrgId": "1",
"Aliases": {
"TestValue": {
"Key": "TestValue",
"Value": "TestValue",
"StylesheetId": null
},
"TestValue2": {
"Key": "TestValue2",
"Value": "TestValue2",
"StylesheetId": null
}
}
}{
- Save document.
- Edit document to the following by removing one value:
"OrgId": "1",
"Aliases": {
"TestValue": {
"Key": "TestValue",
"Value": "TestValue",
"StylesheetId": null
}
}
}
Save the document again and you should see the error.
Doing a little debugging I see the error is thrown when the HttpListenerContextAdapter does FinalizeResponse(). I believe this is causing an underlying crypto stream to get closed at the wrong time. I haven't been able to find out which stream is causing the problem yet or if this is even the real issue. Any help would be appreciated.