Bug 49447

Summary: KeyStoreResolver iterator returns null for symmetric keys
Product: Security - Now in JIRA Reporter: Clement Pellerin <Clement_Pellerin>
Component: EncryptionAssignee: XML Security Developers Mailing List <security-dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows NT   
Bug Depends on:    
Bug Blocks: 49450    
Attachments: patch to solve problem including new junit test

Description Clement Pellerin 2010-06-16 12:29:05 UTC
Created attachment 25599 [details]
patch to solve problem including new junit test

When iterating the certificates in a KeyStoreResolver, the iterator might return null even though hasNext() says there are more elements. This happens because hasNext() only checks if there are more aliases. If the next alias contains a symmetric key, there is no certificate in the KeyStore entry and next() returns null. When you look at the KeyResolvers, they are not prepared to handle a null value, this will cause a NullPointerException.

To reproduce, use the junit KeyStoreResolverTest in the attachment.
Comment 1 coheigea 2010-06-16 13:31:29 UTC
Thanks for the patch, I'll take a look.

Colm.
Comment 2 Clement Pellerin 2010-06-16 15:37:45 UTC
This patch has a bug in the implementation of next() because it never returns NoSuchElementException. See an improvement in the incremental patch attached to Bug 49450.
Comment 3 coheigea 2010-06-17 09:26:05 UTC
Patch applied, thanks.

Colm.