@@ -150,22 +150,24 @@ else if ( ok != X509Utils.X509_LU_FAIL ) {
150
150
return 1 ;
151
151
}
152
152
153
- int idx = X509Object .indexBySubject (store .objects , X509Utils .X509_LU_X509 , xn );
154
- if ( idx == -1 ) return 0 ;
155
-
156
- /* Look through all matching certificates for a suitable issuer */
157
- for ( int i = idx ; i < store .objects .size (); i ++ ) {
158
- final X509Object pobj = store .objects .get (i );
159
- if ( pobj .type () != X509Utils .X509_LU_X509 ) {
160
- return 0 ;
161
- }
162
- final X509AuxCertificate x509 = ((Certificate ) pobj ).x509 ;
163
- if ( ! xn .equalTo ( x509 .getSubjectX500Principal () ) ) {
164
- return 0 ;
165
- }
166
- if ( checkIssued .call (this , x , x509 ) != 0 ) {
167
- issuers [0 ] = x509 ;
168
- return 1 ;
153
+ synchronized (X509Utils .CRYPTO_LOCK_X509_STORE ) {
154
+ int idx = X509Object .indexBySubject (store .getObjects (), X509Utils .X509_LU_X509 , xn );
155
+ if ( idx == -1 ) return 0 ;
156
+
157
+ /* Look through all matching certificates for a suitable issuer */
158
+ for ( int i = idx ; i < store .getObjects ().size (); i ++ ) {
159
+ final X509Object pobj = store .getObjects ().get (i );
160
+ if ( pobj .type () != X509Utils .X509_LU_X509 ) {
161
+ return 0 ;
162
+ }
163
+ final X509AuxCertificate x509 = ((Certificate ) pobj ).x509 ;
164
+ if ( ! xn .equalTo ( x509 .getSubjectX500Principal () ) ) {
165
+ return 0 ;
166
+ }
167
+ if ( checkIssued .call (this , x , x509 ) != 0 ) {
168
+ issuers [0 ] = x509 ;
169
+ return 1 ;
170
+ }
169
171
}
170
172
}
171
173
return 0 ;
@@ -605,9 +607,9 @@ public int setDefault(String name) {
605
607
public int getBySubject (int type ,Name name ,X509Object [] ret ) throws Exception {
606
608
Store c = store ;
607
609
608
- X509Object tmp = X509Object . retrieveBySubject ( c . objects , type , name );
609
- if ( tmp == null ) {
610
- synchronized ( X509Utils . CRYPTO_LOCK_X509_STORE ) {
610
+ synchronized ( X509Utils . CRYPTO_LOCK_X509_STORE ) {
611
+ X509Object tmp = X509Object . retrieveBySubject ( c . getObjects (), type , name );
612
+ if ( tmp == null ) {
611
613
for (int i =currentMethod ; i <c .getCertificateMethods ().size (); i ++) {
612
614
Lookup lu = c .getCertificateMethods ().get (i );
613
615
X509Object [] stmp = new X509Object [1 ];
@@ -625,8 +627,8 @@ else if( j > 0 ) {
625
627
currentMethod = 0 ;
626
628
627
629
if ( tmp == null ) return 0 ;
630
+ ret [0 ] = tmp ;
628
631
}
629
- ret [0 ] = tmp ;
630
632
return 1 ;
631
633
}
632
634
0 commit comments