실제 인증서 디지털서명하기
오후 2:14 2001-04-25 조경민
========================================================
먼저 CAB sdk를 www.microsoft.com 에서 search에서
cab sdk 로 찾아서 cab-sdk.exe를 다운받는다.
ActiveCool.inf
--------------------
[version]
signature="SCHICAGOS"
AdvanceINF=2.0
[Add.Code]
ActiveCool.ocx=ActiveCool.ocx
[ActiveCool.ocx]
file-win32-x86=thiscab
classid={14926478-A07C-49CE-BC69-BD8C8043D07C}
FileVersion=1,0,0,2
RegisterServer=yes
;end of file
----------------------
위 파일과 함께
cabarc -s 6144 n ActiveCool.cab ActiveCool.ocx ActiveCool.inf
이러면 ActiveCool.cab파일이 생기며
versign으로 부터 인증서를 받고 sdk도 받아서
signcode -spc sign.spc -v sign.pvk -t "http://timestamp.verisign.com/scripts/timstamp.dll" -n "AcitveCool 2.0" -i "http://jiran.intracool.co.kr" ActiveCool.cab
이렇게 하면 도중에 암호를 물어보는데 이때 회사 인증서에서 받은 암호를 쓴다.
마지막으로 코드를 바꾸어야한다.
BOOL CActiveCoolCtrl::CActiveCoolCtrlFactory::UpdateRegistry(BOOL bRegister)
이 부분의 코드를 바꾸어야한다.
if (bRegister)
return AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_ACTIVECOOL,
IDB_ACTIVECOOL,
afxRegApartmentThreading,
_dwActiveCoolOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
이런 기존의 코드를 아래처럼 바꾼다.
#include "comcat.h"
#include "objsafe.h"
HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription)
{
ICatRegister* pcr = NULL ; // interface pointer
HRESULT hr = S_OK ;
hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICatRegister,
(void**)&pcr);
if(FAILED(hr))
return hr;
// Make sure the HKCR\Component Categories\{..catid...}
// key is registered
CATEGORYINFO catinfo;
catinfo.catid = catid;
catinfo.lcid = 0x0409 ; // english
// Make sure the provided description is not too long.
// Only copy the first 127 characters if it is
int len = wcslen(catDescription);
if(len>127)
len = 127;
wcsncpy(catinfo.szDescription, catDescription, len);
// Make sure the description is null terminated
catinfo.szDescription[len] = '\0';
hr = pcr->RegisterCategories(1, &catinfo);
pcr->Release();
return hr;
}
HRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid)
{
// Register your component categories information.
ICatRegister* pcr = NULL ;
HRESULT hr = S_OK ;
hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICatRegister,
(void**)&pcr);
if(SUCCEEDED(hr))
{
// Register this category as being "implemented" by
// the class.
CATID rgcatid[1] ;
rgcatid[0] = catid;
hr = pcr->RegisterClassImplCategories(clsid, 1, rgcatid);
}
if(pcr != NULL)
pcr->Release();
return hr;
}
HRESULT UnregisterCLSIDInCategory( REFCLSID clsid, CATID catid )
{
ICatRegister* pcr = NULL;
HRESULT hr = S_OK;
hr = CoCreateInstance( CLSID_StdComponentCategoriesMgr,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICatRegister,
(void**)&pcr );
if( SUCCEEDED(hr) )
{
CATID rgcatid[1];
rgcatid[0] = catid;
hr = pcr->UnRegisterClassImplCategories( clsid, 1, rgcatid );
}
if( pcr != NULL )
pcr->Release();
return hr;
}
BOOL CActiveCoolCtrl::CActiveCoolCtrlFactory::UpdateRegistry(BOOL bRegister)
{
// TODO: Verify that your control follows apartment-model threading rules.
// Refer to MFC TechNote 64 for more information.
// If your control does not conform to the apartment-model rules, then
// you must modify the code below, changing the 6th parameter from
// afxRegApartmentThreading to 0.
/*
if (bRegister)
return AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_ACTIVECOOL,
IDB_ACTIVECOOL,
afxRegApartmentThreading,
_dwActiveCoolOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
*/
if(bRegister)
{
BOOL retval = AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_ACTIVECOOL,
IDB_ACTIVECOOL,
afxRegApartmentThreading,
_dwActiveCoolOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
// mark as safe for scripting--failure OK
HRESULT hr = CreateComponentCategory(CATID_SafeForScripting,
L"Controls that are safely scriptable");
if (SUCCEEDED(hr))
// only register if category exists
RegisterCLSIDInCategory(m_clsid, CATID_SafeForScripting);
// don't care if this call fails
// mark as safe for data initialization
hr = CreateComponentCategory(CATID_SafeForInitializing,
L"Controls safely initializable from persistent data");
if (SUCCEEDED(hr))
// only register if category exists
RegisterCLSIDInCategory(m_clsid, CATID_SafeForInitializing);
// don't care if this call fails
return retval;
}
else
{
UnregisterCLSIDInCategory( m_clsid, CATID_SafeForInitializing );
UnregisterCLSIDInCategory( m_clsid, CATID_SafeForScripting );
return AfxOleUnregisterClass( m_clsid, m_lpszProgID );
}
}
그리고 컴파일할때엔
inf의 파일버전과 컴파일때 리소스 StringTable에서 버전과 (파일버전, 프로덕버전)
그리고 웹페이지의 버전을 명시해서 버전이 높으면 자동으로 다운받도록 하게 한다.
<object id="ActiveCool" width=400 height=300
classid="clsid:14926478-A07C-49CE-BC69-BD8C8043D07C"
codebase="http://211.236.68.76/ActiveCool/ActiveCool.cab#version=1,0,0,2">
</object>
오후 2:14 2001-04-25 조경민
========================================================
먼저 CAB sdk를 www.microsoft.com 에서 search에서
cab sdk 로 찾아서 cab-sdk.exe를 다운받는다.
ActiveCool.inf
--------------------
[version]
signature="SCHICAGOS"
AdvanceINF=2.0
[Add.Code]
ActiveCool.ocx=ActiveCool.ocx
[ActiveCool.ocx]
file-win32-x86=thiscab
classid={14926478-A07C-49CE-BC69-BD8C8043D07C}
FileVersion=1,0,0,2
RegisterServer=yes
;end of file
----------------------
위 파일과 함께
cabarc -s 6144 n ActiveCool.cab ActiveCool.ocx ActiveCool.inf
이러면 ActiveCool.cab파일이 생기며
versign으로 부터 인증서를 받고 sdk도 받아서
signcode -spc sign.spc -v sign.pvk -t "http://timestamp.verisign.com/scripts/timstamp.dll" -n "AcitveCool 2.0" -i "http://jiran.intracool.co.kr" ActiveCool.cab
이렇게 하면 도중에 암호를 물어보는데 이때 회사 인증서에서 받은 암호를 쓴다.
마지막으로 코드를 바꾸어야한다.
BOOL CActiveCoolCtrl::CActiveCoolCtrlFactory::UpdateRegistry(BOOL bRegister)
이 부분의 코드를 바꾸어야한다.
if (bRegister)
return AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_ACTIVECOOL,
IDB_ACTIVECOOL,
afxRegApartmentThreading,
_dwActiveCoolOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
이런 기존의 코드를 아래처럼 바꾼다.
#include "comcat.h"
#include "objsafe.h"
HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription)
{
ICatRegister* pcr = NULL ; // interface pointer
HRESULT hr = S_OK ;
hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICatRegister,
(void**)&pcr);
if(FAILED(hr))
return hr;
// Make sure the HKCR\Component Categories\{..catid...}
// key is registered
CATEGORYINFO catinfo;
catinfo.catid = catid;
catinfo.lcid = 0x0409 ; // english
// Make sure the provided description is not too long.
// Only copy the first 127 characters if it is
int len = wcslen(catDescription);
if(len>127)
len = 127;
wcsncpy(catinfo.szDescription, catDescription, len);
// Make sure the description is null terminated
catinfo.szDescription[len] = '\0';
hr = pcr->RegisterCategories(1, &catinfo);
pcr->Release();
return hr;
}
HRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid)
{
// Register your component categories information.
ICatRegister* pcr = NULL ;
HRESULT hr = S_OK ;
hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICatRegister,
(void**)&pcr);
if(SUCCEEDED(hr))
{
// Register this category as being "implemented" by
// the class.
CATID rgcatid[1] ;
rgcatid[0] = catid;
hr = pcr->RegisterClassImplCategories(clsid, 1, rgcatid);
}
if(pcr != NULL)
pcr->Release();
return hr;
}
HRESULT UnregisterCLSIDInCategory( REFCLSID clsid, CATID catid )
{
ICatRegister* pcr = NULL;
HRESULT hr = S_OK;
hr = CoCreateInstance( CLSID_StdComponentCategoriesMgr,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICatRegister,
(void**)&pcr );
if( SUCCEEDED(hr) )
{
CATID rgcatid[1];
rgcatid[0] = catid;
hr = pcr->UnRegisterClassImplCategories( clsid, 1, rgcatid );
}
if( pcr != NULL )
pcr->Release();
return hr;
}
BOOL CActiveCoolCtrl::CActiveCoolCtrlFactory::UpdateRegistry(BOOL bRegister)
{
// TODO: Verify that your control follows apartment-model threading rules.
// Refer to MFC TechNote 64 for more information.
// If your control does not conform to the apartment-model rules, then
// you must modify the code below, changing the 6th parameter from
// afxRegApartmentThreading to 0.
/*
if (bRegister)
return AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_ACTIVECOOL,
IDB_ACTIVECOOL,
afxRegApartmentThreading,
_dwActiveCoolOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
*/
if(bRegister)
{
BOOL retval = AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_ACTIVECOOL,
IDB_ACTIVECOOL,
afxRegApartmentThreading,
_dwActiveCoolOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
// mark as safe for scripting--failure OK
HRESULT hr = CreateComponentCategory(CATID_SafeForScripting,
L"Controls that are safely scriptable");
if (SUCCEEDED(hr))
// only register if category exists
RegisterCLSIDInCategory(m_clsid, CATID_SafeForScripting);
// don't care if this call fails
// mark as safe for data initialization
hr = CreateComponentCategory(CATID_SafeForInitializing,
L"Controls safely initializable from persistent data");
if (SUCCEEDED(hr))
// only register if category exists
RegisterCLSIDInCategory(m_clsid, CATID_SafeForInitializing);
// don't care if this call fails
return retval;
}
else
{
UnregisterCLSIDInCategory( m_clsid, CATID_SafeForInitializing );
UnregisterCLSIDInCategory( m_clsid, CATID_SafeForScripting );
return AfxOleUnregisterClass( m_clsid, m_lpszProgID );
}
}
그리고 컴파일할때엔
inf의 파일버전과 컴파일때 리소스 StringTable에서 버전과 (파일버전, 프로덕버전)
그리고 웹페이지의 버전을 명시해서 버전이 높으면 자동으로 다운받도록 하게 한다.
<object id="ActiveCool" width=400 height=300
classid="clsid:14926478-A07C-49CE-BC69-BD8C8043D07C"
codebase="http://211.236.68.76/ActiveCool/ActiveCool.cab#version=1,0,0,2">
</object>
'KB > MFC/Win32' 카테고리의 다른 글
MFC ActiveX에서 PARAM 가능하게 하기 (0) | 2004.03.19 |
---|---|
엑티브엑스에서 키, 탭키등을 먹게 하기 (0) | 2004.03.19 |
ActiveX odl에서 CLSID 바꾸기.. (0) | 2004.03.19 |
[winsock] 넌블러킹 I/O중 WSAAyncSelect이용시 OnSend 이벤트 가상으로 발생시키기 (0) | 2004.03.19 |
디버그 컨디션 (0) | 2004.03.19 |