2015년 1월 13일 화요일

윈도 SSL인증서 설치방법~~

http://www.codeproject.com/Messages/1048467/WinHTTP-error-12175-howto.aspx


bool InstallCertificationAuthority()
{
HCERTSTORE hSystemStore;
hSystemStore = CertOpenSystemStore(NULL, _T("ROOT"));
if (hSystemStore == NULL)
return false;
 
// Find the certificate resource
HRSRC hRSRC;
hRSRC = FindResource(AfxGetResourceHandle()MAKEINTRESOURCE(IDR_CERTIFICATE), _T("CERTIFICATE"));
if (hRSRC == NULL)
return false;
 
// Obtain the size of the Certificate resource
DWORD dwSize;
dwSize = SizeofResource(AfxGetResourceHandle(), hRSRC);
if (dwSize == 0)
return false;
 
// Load the resource into a global memory handler
HGLOBAL hCertificate;
hCertificate = LoadResource(AfxGetResourceHandle(), hRSRC);
if (hCertificate == NULL)
return false;
 
// Lock the resource
LPBYTE lpCertificate;
lpCertificate = (LPBYTE) LockResource(hCertificate);
if (lpCertificate == NULL) {
FreeResource(hCertificate);
return false;
}
 
if (!CertAddEncodedCertificateToStore(hSystemStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, lpCertificate, dwSize, CERT_STORE_ADD_USE_EXISTING, NULL)) {
logRPCCore.Output("Cannot install certificate!\n");
}
 
UnlockResource(hCertificate);
FreeResource(hCertificate);
 
CertCloseStore(hSystemStore, 0);
return true;
}

댓글 없음: