Program 기타

Code Signing 만들기 (SelfSignedCertificate 이용)

홍사훈     0건     365회

본문

 

## 컴퓨터에 설치된 인증서 확인 

  Win+R> certmgr.msc


## 인증서 발급

  1. Windows PowerShell 관리자로 실행

  2. New-SelfSignedCertificate 사용

   PS c:\> New-SelfSignedCertificate -Type Custom -Subject "CN=발급명" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.17={text}email=이메일") -KeyUsage DigitalSignature -KeyAlgorithm RSA -KeyLength 2048 -CertStoreLocation "Cert:\CurrentUser\My" -NotAfter (Get-Date).AddYears(5)

  ​Subject의 CN : 인증서에 표시될 이름 

  - TextExtension :인증서가 정보

    2.5.29.37 : 인증서가 사용될 용도

      1.3.6.1.5.5.7.3.2 : Client Authentication.

      1.3.6.1.5.5.7.3.1 : Server Authentication. 

      1.3.6.1.5.5.7.3.4 : Secure Email. 

      1.3.6.1.5.5.7.3.3 : Code Signing. 

      1.3.6.1.5.5.7.3.8 : Timestamp Signing.

    2.5.29.17 : 발급자의 추가 정보

      UPN : A user principal name in the following format: admin@contoso.com

      Email : An email address, such as this example: admin@contoso.com

      DNS : A computer name in the following format: computer.contoso.com

      DirectoryName : CN=Name,DC=Domain,DC=com

      URL : The URL of a host, such as this example: http://computer07.contoso.com/index.html

      IPAddress : An IP address

      RegisteredID : ID in dotted decimal notation, such as this example: 1.2.3.4.5

      GUID : A globally unique ID, such as this example: f7c3ac41-b8ce-4fb4-aa58-3d1dc0e36b39

  - KeyUsage : 키가 사용될 용도 (설정하지 않으면 None)

    CertSign 

    CRLSign

    DataEncipherment

    DecipherOnly

    DigitalSiganture

    EncipherOnly

    KeyAgreement

    KeyEncipherment

    None (default)

    NonRepudiation

  - KeyAlgorithm 키 생성 적용되는 알고리즘

    RSA : bit단위의 키 길이를 설정 (-KeyLength 2048 권장)

  - CertStoreLocation 인증서가 저장될 공간 

    ex) Cert:\CurrentUser\My

  - NotAfter : 인증서 만료일 (따로 정하지 않을 경우 1년)

 

     PSParentPath: Microsoft.PowerShell.Security\Certificate::currentuser\my

    Thumbprint                                Subject 

    ----------                                -------

    41CAC65999A53028D338A4661EE643**********  CN=발급명 

 

   PS c:\> 

 

## 인증서 확인/내보내기

  1. Windows PowerShell 관리자로 실행

 

  2. 인증서 확인

   PS c:\> cd cert:\ 

   PS Cert:\> cd .\\CurrentUser\My\ 

   PS Cert:\CurrentUser\My\> dir 

     PSParentPath: Microsoft.PowerShell.Security\Certificate::currentuser\my

    Thumbprint                                Subject 

    ----------                                -------

    A8F8B60E89D7B8B7EF430478529315**********  CN=844323fc-1332-4f64-9ec6-7fb7946b6c72 

    41CAC65999A53028D338A4661EE643**********  CN=발급명

    344B2D6BE10C3985E9619911D079C9**********  CN=localhost

   PS Cert:\CurrentUser\My\>

 

  3. 인증서 비밀번호 설정

   PS Cert:\CurrentUser\My\> $pwd = ConvertTo-SecureString -String 1234567890 -Force -AsPlainText

  - 1234567890 : 비밀번호

   PS Cert:\CurrentUser\My\> 

 

  4. 인증서 내보내기 

   PS Cert:\CurrentUser\My\> Export-PfxCertificate -cert "Cert:\CurrentUser\My\41CAC65999A53028D338A4661EE643**********" -FilePath c:\test.pfx -Password $pwd 

 

     디렉터리: C:\

  Mode                 LastWriteTime         Length Name 

  ----                 -------------         ------ ----

  -a----      2024-03-16   오후 8:37           2606 test.pfx

 

PS Cert:\currentuser\my\>

 

## signtool을 이용한코드사이닝(code signing)

   PS C:\> signtool sign /f test.pfx /p pfx_패스워드 /fd SHA256 /td SHA256 /tr http://timestamp.digicert.com 실행파일.exe

    Done Adding Additional Store

    Successfully signed: 실행파일.exe 

등록된 댓글이 없습니다.



Copyrightⓡ1996~2025, sahoon.com All Rights Reserved.