반응형
# https://nsis.sourceforge.io/Import_Root_Certificate
# 사용 예
# ${AddCertificateToStore} $0 "$VAR_INSTDIR\rootcert.cer"
!define CERT_QUERY_OBJECT_FILE 1
!define CERT_QUERY_CONTENT_FLAG_ALL 16382
!define CERT_QUERY_FORMAT_FLAG_ALL 14
!define CERT_STORE_PROV_SYSTEM 10
!define CERT_STORE_OPEN_EXISTING_FLAG 0x4000
!define CERT_SYSTEM_STORE_LOCAL_MACHINE 0x20000
!define CERT_STORE_ADD_ALWAYS 4
!macro _AddCertificateToStore un
Function ${un}_AddCertificateToStore
Exch $0
Push $1
Push $R0
System::Call "crypt32::CryptQueryObject(i ${CERT_QUERY_OBJECT_FILE}, w r0, \
i ${CERT_QUERY_CONTENT_FLAG_ALL}, i ${CERT_QUERY_FORMAT_FLAG_ALL}, \
i 0, i 0, i 0, i 0, i 0, i 0, *i .r0) i .R0"
${If} $R0 <> 0
System::Call "crypt32::CertOpenStore(i ${CERT_STORE_PROV_SYSTEM}, i 0, i 0, \
i ${CERT_STORE_OPEN_EXISTING_FLAG}|${CERT_SYSTEM_STORE_LOCAL_MACHINE}, \
w 'ROOT') i .r1"
${If} $1 <> 0
System::Call "crypt32::CertAddCertificateContextToStore(i r1, i r0, \
i ${CERT_STORE_ADD_ALWAYS}, i 0) i .R0"
System::Call "crypt32::CertFreeCertificateContext(i r0)"
${If} $R0 == 0
StrCpy $0 "Unable to add certificate to certificate store"
${Else}
StrCpy $0 "success"
${EndIf}
System::Call "crypt32::CertCloseStore(i r1, i 0)"
${Else}
System::Call "crypt32::CertFreeCertificateContext(i r0)"
StrCpy $0 "Unable to open certificate store"
${EndIf}
${Else}
StrCpy $0 "Unable to open certificate file"
${EndIf}
Pop $R0
Pop $1
Exch $0
FunctionEnd
!macroend
!insertmacro _AddCertificateToStore ""
;!insertmacro _AddCertificateToStore "un."
!macro AddCertificateToStore OUTPUT param
Push "${param}"
!ifndef __UNINSTALL__
Call _AddCertificateToStore
!else
Call un._AddCertificateToStore
!endif
Pop "${OUTPUT}"
!macroend
!define AddCertificateToStore "!insertmacro AddCertificateToStore"
반응형
'NSIS > Reference' 카테고리의 다른 글
[NSIS] 사설 인증서 등록 (2) | 2024.12.25 |
---|---|
[NSIS] 권한 상승 (0) | 2024.12.25 |
[NSIS] 특수 경로 얻어오기 (0) | 2024.12.25 |
[NSIS] 재배포 패키지 설치 여부 체크 후 설치하는 방법 (0) | 2024.12.11 |
[NSIS] 32비트와 64비트 모듈 등록하는 법. (regsvr32) (0) | 2024.12.11 |