[java-opensaml] branch maint-4 updated: OSJ-365 - BasicX509Credential has race condition around cert access

Scott Cantor cantor.2 at osu.edu
Mon Nov 14 17:10:27 UTC 2022


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch maint-4
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=905dc658f8129ba1bae62110040c0baaf474bc45

The following commit(s) were added to refs/heads/maint-4 by this push:
     new 905dc658f OSJ-365 - BasicX509Credential has race condition around cert access
905dc658f is described below

commit 905dc658f8129ba1bae62110040c0baaf474bc45
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Nov 14 12:10:24 2022 -0500

    OSJ-365 - BasicX509Credential has race condition around cert access
    
    https://shibboleth.atlassian.net/browse/OSJ-365
    
    Move sync to object to avoid NPE.
---
 .../main/java/org/opensaml/security/x509/BasicX509Credential.java    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/opensaml-security-api/src/main/java/org/opensaml/security/x509/BasicX509Credential.java b/opensaml-security-api/src/main/java/org/opensaml/security/x509/BasicX509Credential.java
index d6586dbb6..6f18a7cc7 100644
--- a/opensaml-security-api/src/main/java/org/opensaml/security/x509/BasicX509Credential.java
+++ b/opensaml-security-api/src/main/java/org/opensaml/security/x509/BasicX509Credential.java
@@ -32,6 +32,7 @@ import org.opensaml.security.credential.BasicCredential;
 import org.opensaml.security.credential.Credential;
 
 import net.shibboleth.utilities.java.support.annotation.ParameterName;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.collection.LazySet;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
@@ -131,7 +132,7 @@ public class BasicX509Credential extends BasicCredential implements X509Credenti
     /** {@inheritDoc} */
     @Override
     @Nonnull @NonnullElements public Collection<X509Certificate> getEntityCertificateChain() {
-        synchronized(entityCertChain) {
+        synchronized(this) {
             if (entityCertChain == null) {
                 final LazySet<X509Certificate> constructedChain = new LazySet<>();
                 constructedChain.add(entityCert);
@@ -151,7 +152,7 @@ public class BasicX509Credential extends BasicCredential implements X509Credenti
         Constraint.isNotNull(newCertificateChain, "Certificate chain collection cannot be null");
         Constraint.isNotEmpty(newCertificateChain, "Certificate chain collection cannot be empty");
         
-        synchronized(entityCertChain) {
+        synchronized(this) {
             entityCertChain = new ArrayList<>(newCertificateChain);
         }
     }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list