Skip to content

Commit

Permalink
Handle redirect on AIA issuer fetch
Browse files Browse the repository at this point in the history
IB-7006

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed Sep 28, 2021
1 parent f033658 commit 05a938c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/crypto/X509Cert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ X509Cert::X509Cert(const vector<unsigned char> &bytes, Format format)
X509Cert::X509Cert(const unsigned char *bytes, size_t size, Format format)
{
if(!bytes || size == 0)
THROW("No bytes given to parse X509.");
return;
if(format == Der)
{
const unsigned char *p = bytes;
Expand Down
6 changes: 4 additions & 2 deletions src/crypto/X509CertStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ X509Cert X509CertStore::issuerFromAIA(const X509Cert &cert) const
}
if(url.empty())
return X509Cert();
Connect::Result result = Connect(url, "GET", 0, {}).exec();
Connect::Result result = Connect(url, "GET").exec();
if(result.isRedirect())
result = Connect(result.headers["Location"], "GET").exec();
return X509Cert((const unsigned char*)result.content.c_str(), result.content.size());
}

Expand Down Expand Up @@ -278,7 +280,7 @@ bool X509CertStore::verify(const X509Cert &cert, bool noqscd) const
return all_of(policySet.cbegin(), policySet.cend(), containsPolicy);
};
auto matchKeyUsageSet = [&keyUsage](const map<X509Cert::KeyUsage,bool> &keyUsageSet){
return all_of(keyUsageSet.cbegin(), keyUsageSet.cend(), [&keyUsage](const pair<X509Cert::KeyUsage,bool> &keyUsageBit){
return all_of(keyUsageSet.cbegin(), keyUsageSet.cend(), [&keyUsage](pair<X509Cert::KeyUsage, bool> keyUsageBit) {
return (find(keyUsage.cbegin(), keyUsage.cend(), keyUsageBit.first) != keyUsage.cend()) == keyUsageBit.second;
});
};
Expand Down

0 comments on commit 05a938c

Please sign in to comment.