mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Expose additional SSL certificate information.
- Provide access to the full certificate issuer chain (issue #1530) - Add several missing certificate error codes to cef_errorcode_t (issue #1784) - Provide the full certificate status bitmask (issue #1790)
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include <algorithm>
|
||||
#include "libcef_dll/cpptoc/binary_value_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/sslcert_principal_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/sslinfo_cpptoc.h"
|
||||
@@ -19,6 +20,50 @@ namespace {
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
cef_cert_status_t CEF_CALLBACK sslinfo_get_cert_status(
|
||||
struct _cef_sslinfo_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return CERT_STATUS_NONE;
|
||||
|
||||
// Execute
|
||||
cef_cert_status_t _retval = CefSSLInfoCppToC::Get(self)->GetCertStatus();
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK sslinfo_is_cert_status_error(struct _cef_sslinfo_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefSSLInfoCppToC::Get(self)->IsCertStatusError();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK sslinfo_is_cert_status_minor_error(
|
||||
struct _cef_sslinfo_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefSSLInfoCppToC::Get(self)->IsCertStatusMinorError();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_sslcert_principal_t* CEF_CALLBACK sslinfo_get_subject(
|
||||
struct _cef_sslinfo_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@@ -127,12 +172,101 @@ struct _cef_binary_value_t* CEF_CALLBACK sslinfo_get_pemencoded(
|
||||
return CefBinaryValueCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
size_t CEF_CALLBACK sslinfo_get_issuer_chain_size(struct _cef_sslinfo_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
size_t _retval = CefSSLInfoCppToC::Get(self)->GetIssuerChainSize();
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
void CEF_CALLBACK sslinfo_get_derencoded_issuer_chain(
|
||||
struct _cef_sslinfo_t* self, size_t* chainCount,
|
||||
struct _cef_binary_value_t** chain) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: chain; type: refptr_vec_same_byref
|
||||
DCHECK(chainCount && (*chainCount == 0 || chain));
|
||||
if (!chainCount || (*chainCount > 0 && !chain))
|
||||
return;
|
||||
|
||||
// Translate param: chain; type: refptr_vec_same_byref
|
||||
std::vector<CefRefPtr<CefBinaryValue> > chainList;
|
||||
if (chainCount && *chainCount > 0 && chain) {
|
||||
for (size_t i = 0; i < *chainCount; ++i) {
|
||||
chainList.push_back(CefBinaryValueCppToC::Unwrap(chain[i]));
|
||||
}
|
||||
}
|
||||
|
||||
// Execute
|
||||
CefSSLInfoCppToC::Get(self)->GetDEREncodedIssuerChain(
|
||||
chainList);
|
||||
|
||||
// Restore param: chain; type: refptr_vec_same_byref
|
||||
if (chainCount && chain) {
|
||||
*chainCount = std::min(chainList.size(), *chainCount);
|
||||
if (*chainCount > 0) {
|
||||
for (size_t i = 0; i < *chainCount; ++i) {
|
||||
chain[i] = CefBinaryValueCppToC::Wrap(chainList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEF_CALLBACK sslinfo_get_pemencoded_issuer_chain(
|
||||
struct _cef_sslinfo_t* self, size_t* chainCount,
|
||||
struct _cef_binary_value_t** chain) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: chain; type: refptr_vec_same_byref
|
||||
DCHECK(chainCount && (*chainCount == 0 || chain));
|
||||
if (!chainCount || (*chainCount > 0 && !chain))
|
||||
return;
|
||||
|
||||
// Translate param: chain; type: refptr_vec_same_byref
|
||||
std::vector<CefRefPtr<CefBinaryValue> > chainList;
|
||||
if (chainCount && *chainCount > 0 && chain) {
|
||||
for (size_t i = 0; i < *chainCount; ++i) {
|
||||
chainList.push_back(CefBinaryValueCppToC::Unwrap(chain[i]));
|
||||
}
|
||||
}
|
||||
|
||||
// Execute
|
||||
CefSSLInfoCppToC::Get(self)->GetPEMEncodedIssuerChain(
|
||||
chainList);
|
||||
|
||||
// Restore param: chain; type: refptr_vec_same_byref
|
||||
if (chainCount && chain) {
|
||||
*chainCount = std::min(chainList.size(), *chainCount);
|
||||
if (*chainCount > 0) {
|
||||
for (size_t i = 0; i < *chainCount; ++i) {
|
||||
chain[i] = CefBinaryValueCppToC::Wrap(chainList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefSSLInfoCppToC::CefSSLInfoCppToC() {
|
||||
GetStruct()->get_cert_status = sslinfo_get_cert_status;
|
||||
GetStruct()->is_cert_status_error = sslinfo_is_cert_status_error;
|
||||
GetStruct()->is_cert_status_minor_error = sslinfo_is_cert_status_minor_error;
|
||||
GetStruct()->get_subject = sslinfo_get_subject;
|
||||
GetStruct()->get_issuer = sslinfo_get_issuer;
|
||||
GetStruct()->get_serial_number = sslinfo_get_serial_number;
|
||||
@@ -140,6 +274,11 @@ CefSSLInfoCppToC::CefSSLInfoCppToC() {
|
||||
GetStruct()->get_valid_expiry = sslinfo_get_valid_expiry;
|
||||
GetStruct()->get_derencoded = sslinfo_get_derencoded;
|
||||
GetStruct()->get_pemencoded = sslinfo_get_pemencoded;
|
||||
GetStruct()->get_issuer_chain_size = sslinfo_get_issuer_chain_size;
|
||||
GetStruct()->get_derencoded_issuer_chain =
|
||||
sslinfo_get_derencoded_issuer_chain;
|
||||
GetStruct()->get_pemencoded_issuer_chain =
|
||||
sslinfo_get_pemencoded_issuer_chain;
|
||||
}
|
||||
|
||||
template<> CefRefPtr<CefSSLInfo> CefCppToC<CefSSLInfoCppToC, CefSSLInfo,
|
||||
|
@@ -10,6 +10,7 @@
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include <algorithm>
|
||||
#include "libcef_dll/ctocpp/binary_value_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/sslcert_principal_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/sslinfo_ctocpp.h"
|
||||
@@ -17,6 +18,48 @@
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
cef_cert_status_t CefSSLInfoCToCpp::GetCertStatus() {
|
||||
cef_sslinfo_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_cert_status))
|
||||
return CERT_STATUS_NONE;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_cert_status_t _retval = _struct->get_cert_status(_struct);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
bool CefSSLInfoCToCpp::IsCertStatusError() {
|
||||
cef_sslinfo_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, is_cert_status_error))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->is_cert_status_error(_struct);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
bool CefSSLInfoCToCpp::IsCertStatusMinorError() {
|
||||
cef_sslinfo_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, is_cert_status_minor_error))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->is_cert_status_minor_error(_struct);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefSSLCertPrincipal> CefSSLInfoCToCpp::GetSubject() {
|
||||
cef_sslinfo_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_subject))
|
||||
@@ -115,6 +158,98 @@ CefRefPtr<CefBinaryValue> CefSSLInfoCToCpp::GetPEMEncoded() {
|
||||
return CefBinaryValueCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
size_t CefSSLInfoCToCpp::GetIssuerChainSize() {
|
||||
cef_sslinfo_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_issuer_chain_size))
|
||||
return 0;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
size_t _retval = _struct->get_issuer_chain_size(_struct);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
void CefSSLInfoCToCpp::GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) {
|
||||
cef_sslinfo_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_derencoded_issuer_chain))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Translate param: chain; type: refptr_vec_same_byref
|
||||
size_t chainSize = chain.size();
|
||||
size_t chainCount = std::max(GetIssuerChainSize(), chainSize);
|
||||
cef_binary_value_t** chainList = NULL;
|
||||
if (chainCount > 0) {
|
||||
chainList = new cef_binary_value_t*[chainCount];
|
||||
DCHECK(chainList);
|
||||
if (chainList) {
|
||||
memset(chainList, 0, sizeof(cef_binary_value_t*)*chainCount);
|
||||
}
|
||||
if (chainList && chainSize > 0) {
|
||||
for (size_t i = 0; i < chainSize; ++i) {
|
||||
chainList[i] = CefBinaryValueCToCpp::Unwrap(chain[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Execute
|
||||
_struct->get_derencoded_issuer_chain(_struct,
|
||||
&chainCount,
|
||||
chainList);
|
||||
|
||||
// Restore param:chain; type: refptr_vec_same_byref
|
||||
chain.clear();
|
||||
if (chainCount > 0 && chainList) {
|
||||
for (size_t i = 0; i < chainCount; ++i) {
|
||||
chain.push_back(CefBinaryValueCToCpp::Wrap(chainList[i]));
|
||||
}
|
||||
delete [] chainList;
|
||||
}
|
||||
}
|
||||
|
||||
void CefSSLInfoCToCpp::GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) {
|
||||
cef_sslinfo_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_pemencoded_issuer_chain))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Translate param: chain; type: refptr_vec_same_byref
|
||||
size_t chainSize = chain.size();
|
||||
size_t chainCount = std::max(GetIssuerChainSize(), chainSize);
|
||||
cef_binary_value_t** chainList = NULL;
|
||||
if (chainCount > 0) {
|
||||
chainList = new cef_binary_value_t*[chainCount];
|
||||
DCHECK(chainList);
|
||||
if (chainList) {
|
||||
memset(chainList, 0, sizeof(cef_binary_value_t*)*chainCount);
|
||||
}
|
||||
if (chainList && chainSize > 0) {
|
||||
for (size_t i = 0; i < chainSize; ++i) {
|
||||
chainList[i] = CefBinaryValueCToCpp::Unwrap(chain[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Execute
|
||||
_struct->get_pemencoded_issuer_chain(_struct,
|
||||
&chainCount,
|
||||
chainList);
|
||||
|
||||
// Restore param:chain; type: refptr_vec_same_byref
|
||||
chain.clear();
|
||||
if (chainCount > 0 && chainList) {
|
||||
for (size_t i = 0; i < chainCount; ++i) {
|
||||
chain.push_back(CefBinaryValueCToCpp::Wrap(chainList[i]));
|
||||
}
|
||||
delete [] chainList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
|
@@ -30,6 +30,9 @@ class CefSSLInfoCToCpp
|
||||
CefSSLInfoCToCpp();
|
||||
|
||||
// CefSSLInfo methods.
|
||||
cef_cert_status_t GetCertStatus() OVERRIDE;
|
||||
bool IsCertStatusError() OVERRIDE;
|
||||
bool IsCertStatusMinorError() OVERRIDE;
|
||||
CefRefPtr<CefSSLCertPrincipal> GetSubject() OVERRIDE;
|
||||
CefRefPtr<CefSSLCertPrincipal> GetIssuer() OVERRIDE;
|
||||
CefRefPtr<CefBinaryValue> GetSerialNumber() OVERRIDE;
|
||||
@@ -37,6 +40,9 @@ class CefSSLInfoCToCpp
|
||||
CefTime GetValidExpiry() OVERRIDE;
|
||||
CefRefPtr<CefBinaryValue> GetDEREncoded() OVERRIDE;
|
||||
CefRefPtr<CefBinaryValue> GetPEMEncoded() OVERRIDE;
|
||||
size_t GetIssuerChainSize() OVERRIDE;
|
||||
void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) OVERRIDE;
|
||||
void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
|
Reference in New Issue
Block a user