Skip to content

Commit

Permalink
cryptocrl: adapt to new XrdSutCache
Browse files Browse the repository at this point in the history
  • Loading branch information
gganis committed Jul 6, 2017
1 parent fcb5be4 commit 621e508
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
28 changes: 12 additions & 16 deletions src/XrdCrypto/XrdCryptosslX509Crl.cc
Expand Up @@ -350,7 +350,6 @@ int XrdCryptosslX509Crl::LoadCache()
// Load relevant info into the cache
// Return 0 if ok, -1 in case of error
EPNAME("LoadCache");
XrdSutCacheRef pfeRef;

// The CRL must exists
if (!crl) {
Expand Down Expand Up @@ -381,12 +380,6 @@ int XrdCryptosslX509Crl::LoadCache()
return 0;
}

// Init cache
if (cache.Init(nrevoked) != 0) {
DEBUG("problems init cache for CRL info");
return -1;
}

// Get serial numbers of revoked certificates
char *tagser = 0;
int i = 0;
Expand All @@ -404,7 +397,8 @@ int XrdCryptosslX509Crl::LoadCache()
TRACE(Dump, "certificate with serial number: "<<tagser<<
" has been revoked");
// Add to the cache
XrdSutPFEntry *cent = cache.Add(pfeRef, (const char *)tagser);
bool rdlock = false;
XrdSutCacheEntry *cent = cache.Get((const char *)tagser, rdlock);
if (!cent) {
DEBUG("problems updating the cache");
return -1;
Expand All @@ -413,13 +407,11 @@ int XrdCryptosslX509Crl::LoadCache()
cent->mtime = XrdCryptosslASN1toUTC(X509_REVOKED_get0_revocationDate(rev));
// Release the string for the serial number
OPENSSL_free(tagser);
// Unlock the entry
cent->rwmtx.UnLock();
}
}

// rehash the cache
pfeRef.UnLock(); // Prevent lock inversion (though it doesn't matter here)
cache.Rehash(1);

return 0;
}

Expand Down Expand Up @@ -550,7 +542,6 @@ bool XrdCryptosslX509Crl::IsRevoked(int serialnumber, int when)
// Check if certificate with serialnumber is in the
// list of revocated certificates
EPNAME("IsRevoked");
XrdSutCacheRef pfeRef;

// Reference time
int now = (when > 0) ? when : time(0);
Expand All @@ -571,13 +562,16 @@ bool XrdCryptosslX509Crl::IsRevoked(int serialnumber, int when)
sprintf(tagser,"%x",serialnumber);

// Look into the cache
XrdSutPFEntry *cent = cache.Get(pfeRef, (const char *)tagser);
bool rdlock = false;
XrdSutCacheEntry *cent = cache.Get((const char *)tagser, rdlock);
if (cent) {
// Check the revocation time
if (now > cent->mtime) {
DEBUG("certificate "<<tagser<<" has been revoked");
cent->rwmtx.UnLock();
return 1;
}
cent->rwmtx.UnLock();
}

// Certificate not revoked
Expand All @@ -590,7 +584,6 @@ bool XrdCryptosslX509Crl::IsRevoked(const char *sernum, int when)
// Check if certificate with 'sernum' is in the
// list of revocated certificates
EPNAME("IsRevoked");
XrdSutCacheRef pfeRef;

// Reference time
int now = (when > 0) ? when : time(0);
Expand All @@ -607,13 +600,16 @@ bool XrdCryptosslX509Crl::IsRevoked(const char *sernum, int when)
}

// Look into the cache
XrdSutPFEntry *cent = cache.Get(pfeRef, (const char *)sernum);
bool rdlock = false;
XrdSutCacheEntry *cent = cache.Get((const char *)sernum, rdlock);
if (cent) {
// Check the revocation time
if (now > cent->mtime) {
DEBUG("certificate "<<sernum<<" has been revoked");
cent->rwmtx.UnLock();
return 1;
}
cent->rwmtx.UnLock();
}

// Certificate not revoked
Expand Down
1 change: 0 additions & 1 deletion src/XrdCrypto/XrdCryptosslX509Crl.hh
Expand Up @@ -45,7 +45,6 @@
//
// ---------------------------------------------------------------------------//

class XrdSutCache;
class XrdCryptoX509;

class XrdCryptosslX509Crl : public XrdCryptoX509Crl {
Expand Down

0 comments on commit 621e508

Please sign in to comment.