Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Unified Diff: rtc_base/opensslstreamadapter.cc

Issue 3010363002: Implement GetChain for OpenSSLCertificate.
Patch Set: Adding unit tests and clean up. Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « rtc_base/opensslidentity_unittest.cc ('k') | rtc_base/sslstreamadapter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: rtc_base/opensslstreamadapter.cc
diff --git a/rtc_base/opensslstreamadapter.cc b/rtc_base/opensslstreamadapter.cc
index 6fad7f9d488a69ea40fab6926ac19a5cc79f423e..1a6aa8a0526d7522de9144f776ec5443572d0c38 100644
--- a/rtc_base/opensslstreamadapter.cc
+++ b/rtc_base/opensslstreamadapter.cc
@@ -38,6 +38,7 @@
namespace {
bool g_use_time_callback_for_testing = false;
+ const int kMaxSupportedCertChainDepth = 3;
}
namespace rtc {
@@ -1112,18 +1113,16 @@ int OpenSSLStreamAdapter::SSLVerifyCallback(int ok, X509_STORE_CTX* store) {
// For now we ignore the parent certificates and verify the leaf against
// the digest.
//
- // TODO(jiayl): Verify the chain is a proper chain and report the chain to
- // |stream->peer_certificate_|.
- if (depth > 0) {
- LOG(LS_INFO) << "Ignored chained certificate at depth " << depth;
- return 1;
- }
OpenSSLStreamAdapter* stream =
reinterpret_cast<OpenSSLStreamAdapter*>(SSL_get_app_data(ssl));
- // Record the peer's certificate.
- stream->peer_certificate_.reset(new OpenSSLCertificate(cert));
+ STACK_OF(X509)* chain = X509_STORE_CTX_get_chain(store);
+ if (sk_X509_num(chain) >= kMaxSupportedCertChainDepth) {
+ LOG(LS_INFO) << "Ignore chained certificate at depth " << depth;
+ return 1;
+ }
+ stream->peer_certificate_.reset(new OpenSSLCertificate(chain));
// If the peer certificate digest isn't known yet, we'll wait to verify
// until it's known, and for now just return a success status.
« no previous file with comments | « rtc_base/opensslidentity_unittest.cc ('k') | rtc_base/sslstreamadapter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698