// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/browser/certificate_viewer.h" #include #include #include #include "base/logging.h" #include "base/mac/scoped_cftyperef.h" #include "net/base/x509_certificate.h" void ShowCertificateViewer(gfx::NativeWindow parent, net::X509Certificate* cert) { SecCertificateRef cert_mac = cert->os_cert_handle(); if (!cert_mac) return; base::mac::ScopedCFTypeRef certificates( CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); if (!certificates.get()) { NOTREACHED(); return; } CFArrayAppendValue(certificates, cert_mac); // Server certificate must be first in the array; subsequent certificates // in the chain can be in any order. const std::vector& ca_certs = cert->GetIntermediateCertificates(); for (size_t i = 0; i < ca_certs.size(); ++i) CFArrayAppendValue(certificates, ca_certs[i]); [[[SFCertificatePanel alloc] init] beginSheetForWindow:parent modalDelegate:nil didEndSelector:NULL contextInfo:NULL certificates:reinterpret_cast(certificates.get()) showGroup:YES]; // The SFCertificatePanel releases itself when the sheet is dismissed. }