@@ -260,6 +260,7 @@ func (c *crypt) executeStateMachine(ctx context.Context, cryptCtx *mongocrypt.Co
260260 var err error
261261 for {
262262 state := cryptCtx .State ()
263+ fmt .Println ("state" , state )
263264 switch state {
264265 case mongocrypt .NeedMongoCollInfo :
265266 err = c .collectionInfo (ctx , cryptCtx , db )
@@ -341,6 +342,7 @@ func (c *crypt) retrieveKeys(ctx context.Context, cryptCtx *mongocrypt.Context)
341342}
342343
343344func (c * crypt ) decryptKeys (cryptCtx * mongocrypt.Context ) error {
345+ c .mongoCrypt .EnableRetry ()
344346 for {
345347 kmsCtx := cryptCtx .NextKmsContext ()
346348 if kmsCtx == nil {
@@ -388,6 +390,7 @@ func (c *crypt) decryptKey(kmsCtx *mongocrypt.KmsContext) error {
388390 return err
389391 }
390392 if _ , err = conn .Write (msg ); err != nil {
393+ fmt .Println ("conn write" , err )
391394 return err
392395 }
393396
@@ -400,6 +403,11 @@ func (c *crypt) decryptKey(kmsCtx *mongocrypt.KmsContext) error {
400403 res := make ([]byte , bytesNeeded )
401404 bytesRead , err := conn .Read (res )
402405 if err != nil && ! errors .Is (err , io .EOF ) {
406+ fail := kmsCtx .Fail ()
407+ fmt .Println ("conn read" , err , fail )
408+ if fail {
409+ continue
410+ }
403411 return err
404412 }
405413
0 commit comments