Changeset 4ca12d1 for core


Ignore:
Timestamp:
Apr 2, 2018 6:04:32 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
1a7e71c
Parents:
9c2994c
Message:

KeyStore?: Fix ConncurrentModificationException? (ticket #2196)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/crypto/KeyStoreUtil.java

    r9c2994c r4ca12d1  
    399399     *  @since 0.9.24
    400400     */
    401     private static int removeBlacklistedCerts(KeyStore ks) {
     401    private synchronized static int removeBlacklistedCerts(KeyStore ks) {
    402402        if (SystemVersion.isAndroid())
    403403            return 0;
    404         int count = 0;
     404        List<String> toRemove = new ArrayList<String>(4);
    405405        try {
    406406            MessageDigest md = SHA1.getInstance();
     
    430430                            //info("hex is: " + buf);
    431431                            if (_blacklist.contains(new SHA1Hash(h))) {
    432                                 ks.deleteEntry(alias);
    433                                 count++;
     432                                toRemove.add(alias);
    434433                                if (!_blacklistLogged) {
    435434                                    // should this be a logAlways?
     
    451450            }
    452451        } catch (GeneralSecurityException e) {}
    453         if (count > 0)
     452        if (!toRemove.isEmpty()) {
    454453            _blacklistLogged = true;
    455         return count;
     454            for (String alias : toRemove) {
     455                try {
     456                    ks.deleteEntry(alias);
     457                } catch (GeneralSecurityException e) {}
     458            }
     459        }
     460        return toRemove.size();
    456461    }
    457462
     
    12361241     *          KeyStoreUtil foo.ks (loads from system keystore, and from foo.ks keystore if exists, else creates empty)
    12371242     *          KeyStoreUtil certDir (loads from system keystore and all certs in certDir if exists)
    1238      *          KeyStoreUtil import file.ks file.key alias keypw (imxports private key from file to keystore)
     1243     *          KeyStoreUtil import file.ks file.key alias keypw (imports private key from file to keystore)
    12391244     *          KeyStoreUtil export file.ks alias keypw (exports private key from keystore)
    12401245     *          KeyStoreUtil keygen file.ks alias keypw (create keypair in keystore)
Note: See TracChangeset for help on using the changeset viewer.