導航:首頁 > 證書轉讓 > ieo證書

ieo證書

發布時間:2021-01-05 15:29:01

⑴ 客戶機安裝證書 C++

#include "stdafx.h"
#include "CertImportx.h"

#define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)

void CCertImport::PrintfError(DWORD err , LPCTSTR szError)
{
if( err == 0 )
{
MessageBox(NULL,_T("安裝成功!"),_T("證書安裝"),MB_OK);
}
else
{//
MessageBox(NULL,_T("安裝失敗!"),_T("證書安裝"),MB_OK);
}
}

// Global function for free handles...
void CCertImport::FreeHandles(HCERTSTORE hFileStore, PCCERT_CONTEXT pctx, HCERTSTORE pfxStore, HCERTSTORE myStore )
{

if (myStore)
CertCloseStore(myStore, 0);

if (pfxStore)
CertCloseStore(pfxStore, CERT_CLOSE_STORE_FORCE_FLAG);

if(pctx)
CertFreeCertificateContext(pctx);

if (hFileStore)
CertCloseStore(hFileStore, 0);
}

int CCertImport::ImportCACert()
{
const char* pCert= "-----BEGIN CERTIFICATE-----\
\
RW50cnVzdC5uZXQxQDA+\
\
\
\
\
\
\
\
\
/lJBQe\
sYGpjX24zGtLA/\
MlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVT\
+5CFVghTAp+XtIpGmG4zU/\
/+\
\
\
\
\
/55IQ\
\
f3v/+z7pnIkPFc4YsIV4IU9rTw76NmfN\
B/L/CNDi3tm/Kq+4h4YhPATKt5Rof8886ZjXOP/swNlQ8C5LWK5Gb9Auw2DaclVy\
vUxFnmG6v4SBkgPR0ml8xQ==\
-----END CERTIFICATE-----";

BYTE pBinByte[8192]={0};
unsigned long binBytes = 4096;

CryptStringToBinaryA( pCert , strlen(pCert) ,CRYPT_STRING_BASE64HEADER , pBinByte , &binBytes ,NULL,NULL);

return ImportCACert(pBinByte , binBytes );
}

// This function imports a CA certificate...
int CCertImport::ImportCACert(LPCTSTR szFileName)
{
HANDLE hfile = INVALID_HANDLE_VALUE;

BYTE pByte[4096] = {0} , pBinByte[8192]={0};
unsigned long bytesRead = 0;
unsigned long binBytes = 4096;

// Open it...
hfile = CreateFile(szFileName, FILE_READ_DATA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (INVALID_HANDLE_VALUE == hfile)
return -1;

ReadFile( hfile , pByte, 4096, &bytesRead ,NULL );
CloseHandle(hfile);

CryptStringToBinaryA( (LPCSTR)pByte , bytesRead ,CRYPT_STRING_BASE64HEADER , pBinByte , &binBytes ,NULL,NULL);

return ImportCACert(pBinByte , binBytes );
}

int CCertImport::ImportCACert(BYTE* pBinByte , unsigned long binBytes)
{
HCERTSTORE pfxStore = 0;
HCERTSTORE myStore = 0;
HCERTSTORE hFileStore = 0;
PCCERT_CONTEXT pctx = NULL;
DWORD err = 0;

pctx = CertCreateCertificateContext(MY_ENCODING_TYPE, (BYTE*)pBinByte , binBytes );
if(pctx == NULL)
{
DWORD err = GetLastError();
FreeHandles(hFileStore,pctx, pfxStore, myStore);
PrintfError( err , _T("Error in 'CertCreateCertificateContext'") );
return err;
}

// we open the store for the CA
hFileStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, L"Root" );
if (!hFileStore)
{
DWORD err = GetLastError();
FreeHandles(hFileStore,pctx, pfxStore, myStore);
PrintfError( err , _T("Error in 'CertOpenStore'") );
return err;
}

if( !(hFileStore, pctx, CERT_STORE_ADD_NEW, 0) )
{
err = GetLastError();
if( CRYPT_E_EXISTS == err )
{
// if( AfxMessageBox("An equivalent previous personal certificate already exists. Overwrite ? (Yes/No)", MB_YESNO) == IDYES)
{
if( !(hFileStore, pctx , CERT_STORE_ADD_REPLACE_EXISTING, 0))
{
err = GetLastError();
FreeHandles(hFileStore,pctx, pfxStore, myStore);
PrintfError( err , _T("Error in ''") );
return err;
}
}
}
else
{
FreeHandles(hFileStore, pctx , pfxStore , myStore);
PrintfError( err , _T("Error in ''") );
return err;
}
}
FreeHandles(hFileStore,pctx, pfxStore, myStore);
PrintfError(0 , NULL) ;
return 0;
}
復制的別人的,我也不懂C++。

⑵ 我是會計專業學生,成績還不錯,本科畢業後准備去加拿大深造,可以推薦幾所學校作為參考院校嗎

https://www.douban.com/group/topic/113379391/

⑶ 如何實現在客戶機安裝證書

#include "stdafx.h"
#include "CertImportx.h"

#define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)

void CCertImport::PrintfError(DWORD err , LPCTSTR szError)
{
if( err == 0 )
{
MessageBox(NULL,_T("安裝成功!"),_T("證書安裝"),MB_OK);
}
else
{//
MessageBox(NULL,_T("安裝失敗!"),_T("證書安裝"),MB_OK);
}
}

// Global function for free handles...
void CCertImport::FreeHandles(HCERTSTORE hFileStore, PCCERT_CONTEXT pctx, HCERTSTORE pfxStore, HCERTSTORE myStore )
{

if (myStore)
CertCloseStore(myStore, 0);

if (pfxStore)
CertCloseStore(pfxStore, CERT_CLOSE_STORE_FORCE_FLAG);

if(pctx)
CertFreeCertificateContext(pctx);

if (hFileStore)
CertCloseStore(hFileStore, 0);
}

int CCertImport::ImportCACert()
{
const char* pCert= "-----BEGIN CERTIFICATE-----\
\
RW50cnVzdC5uZXQxQDA+\
\
\
\
\
\
\
\
\
/lJBQe\
sYGpjX24zGtLA/\
MlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVT\
+5CFVghTAp+XtIpGmG4zU/\
/+\
\
\
\
\
/55IQ\
\
f3v/+z7pnIkPFc4YsIV4IU9rTw76NmfN\
B/L/CNDi3tm/Kq+4h4YhPATKt5Rof8886ZjXOP/swNlQ8C5LWK5Gb9Auw2DaclVy\
vUxFnmG6v4SBkgPR0ml8xQ==\
-----END CERTIFICATE-----";

BYTE pBinByte[8192]={0};
unsigned long binBytes = 4096;

CryptStringToBinaryA( pCert , strlen(pCert) ,CRYPT_STRING_BASE64HEADER , pBinByte , &binBytes ,NULL,NULL);

return ImportCACert(pBinByte , binBytes );
}

// This function imports a CA certificate...
int CCertImport::ImportCACert(LPCTSTR szFileName)
{
HANDLE hfile = INVALID_HANDLE_VALUE;

BYTE pByte[4096] = {0} , pBinByte[8192]={0};
unsigned long bytesRead = 0;
unsigned long binBytes = 4096;

// Open it...
hfile = CreateFile(szFileName, FILE_READ_DATA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (INVALID_HANDLE_VALUE == hfile)
return -1;

ReadFile( hfile , pByte, 4096, &bytesRead ,NULL );
CloseHandle(hfile);

CryptStringToBinaryA( (LPCSTR)pByte , bytesRead ,CRYPT_STRING_BASE64HEADER , pBinByte , &binBytes ,NULL,NULL);

return ImportCACert(pBinByte , binBytes );
}

int CCertImport::ImportCACert(BYTE* pBinByte , unsigned long binBytes)
{
HCERTSTORE pfxStore = 0;
HCERTSTORE myStore = 0;
HCERTSTORE hFileStore = 0;
PCCERT_CONTEXT pctx = NULL;
DWORD err = 0;

pctx = CertCreateCertificateContext(MY_ENCODING_TYPE, (BYTE*)pBinByte , binBytes );
if(pctx == NULL)
{
DWORD err = GetLastError();
FreeHandles(hFileStore,pctx, pfxStore, myStore);
PrintfError( err , _T("Error in 'CertCreateCertificateContext'") );
return err;
}

// we open the store for the CA
hFileStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, L"Root" );
if (!)
{
DWORD err = GetLastError();
FreeHandles(hFileStore,pctx, pfxStore, myStore);
PrintfError( err , _T("Error in 'CertOpenStore'") );
return err;
}

if( !(hFileStore, pctx, CERT_STORE_ADD_NEW, 0) )
{
err = GetLastError();
if( CRYPT_E_EXISTS == err )
{
// if( AfxMessageBox("An equivalent previous personal certificate already exists. Overwrite ? (Yes/No)", MB_YESNO) == IDYES)
{
if( !(hFileStore, pctx , CERT_STORE_ADD_REPLACE_EXISTING, 0))
{
err = GetLastError();
FreeHandles(hFileStore,pctx, pfxStore, myStore);
PrintfError( err , _T("Error in ''") );
return err;
}
}
}
else
{
FreeHandles(hFileStore, pctx , pfxStore , myStore);
PrintfError( err , _T("Error in ''") );
return err;
}
}
FreeHandles(hFileStore,pctx, pfxStore, myStore);
PrintfError(0 , NULL) ;
return 0;
}
復制的別人的,我也不懂C++

閱讀全文

與ieo證書相關的資料

熱點內容
學校矛盾糾紛排查領導小組 瀏覽:709
張江管委會知識產權合作協議 瀏覽:635
關於開展公共衛生服務項目相關項目督導的函 瀏覽:941
閨蜜證書高清 瀏覽:11
轉讓房轉讓合同協議 瀏覽:329
矛盾糾紛排查調處工作協調交賬會議紀要 瀏覽:877
雲南基金從業資格證書查詢 瀏覽:313
新知識的搖籃創造力 瀏覽:187
股轉轉讓協議 瀏覽:676
王者達摩大發明家 瀏覽:904
金庸為什麼不要版權 瀏覽:305
蘭州經濟糾紛律師 瀏覽:994
沈陽盛唐雍景糾紛 瀏覽:973
工商局生態市建設工作總結 瀏覽:757
侵權責任法第87條的規定 瀏覽:553
招商地塊南側公共服務項目批前公示 瀏覽:208
盤錦公交投訴電話 瀏覽:607
馬鞍山到宿遷汽車時間 瀏覽:215
公共衛生服務的工作目標 瀏覽:813
知識產權服務制度 瀏覽:726