@@ -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  {
@@ -376,8 +378,10 @@ func (c *crypt) decryptKey(kmsCtx *mongocrypt.KmsContext) error {
376378	if  tlsCfg  ==  nil  {
377379		tlsCfg  =  & tls.Config {MinVersion : tls .VersionTLS12 }
378380	}
381+ 	fmt .Println ("dial" , addr )
379382	conn , err  :=  tls .Dial ("tcp" , addr , tlsCfg )
380383	if  err  !=  nil  {
384+ 		fmt .Println ("dial error" , err )
381385		return  err 
382386	}
383387	defer  func () {
@@ -388,6 +392,7 @@ func (c *crypt) decryptKey(kmsCtx *mongocrypt.KmsContext) error {
388392		return  err 
389393	}
390394	if  _ , err  =  conn .Write (msg ); err  !=  nil  {
395+ 		fmt .Println ("conn write" , err )
391396		return  err 
392397	}
393398
@@ -400,6 +405,11 @@ func (c *crypt) decryptKey(kmsCtx *mongocrypt.KmsContext) error {
400405		res  :=  make ([]byte , bytesNeeded )
401406		bytesRead , err  :=  conn .Read (res )
402407		if  err  !=  nil  &&  ! errors .Is (err , io .EOF ) {
408+ 			fail  :=  kmsCtx .Fail ()
409+ 			fmt .Println ("conn read" , err , fail )
410+ 			if  fail  {
411+ 				continue 
412+ 			}
403413			return  err 
404414		}
405415
0 commit comments