2017-09-13 1 views
0

확인 - 정말 이상합니다. 파일에 서명하고 위에 메시지를 가져 오는 TFS 빌드가 있습니다. 빌드에서 로그를 보면 내 파일에 서명하고 타임 스탬프를 찍었다 고합니다. (수동으로 signtool을 호출하는 .proj 파일이 있지만) 다른 단계에서는 정확하지 않습니다. ClickOnce 서명을하면 오류가 발생합니다.서명하는 중 오류가 발생했습니다 : file.exe에 서명하지 못했습니다. SignTool 오류 : 지정된 조건을 모두 충족하는 인증서가 없습니다.

저는 빌드 사용과 동일한 매개 변수를 사용하여 Signtool을 사용하여 직접 파일에 서명 할 수 있으므로 인증서를 가져올 필요가 있다고 생각하여 mmc을 열고 인증서 스냅인을 추가하고 가져 오기를 거쳤습니다. 마법사는 로컬 컴퓨터를 사용하여 설치합니다. TFS 빌드는 내 계정과 다른 계정으로 실행되며 해당 계정의 암호를 모르므로 컴퓨터 수준에서 설치하면 작동합니다. 파일을 찾아보고 신뢰할 수있는 루트 인증 기관 (아래 참조)에서 성공적으로 가져 왔습니다.

enter image description here 여전히 빌드 할 때 오류가 발생합니다. signtool은 TFS 빌드에서 호출 된 .proj 파일에서 호출되지만 ClickOnce에서 빌드에 의해 다시 호출됩니다. enter image description here

을 그리고이 오류 : 다음 VS 화면을 통해 인증서를 가져온 후 지금 이것을 볼

C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (2718): Unable to find code signing certificate in the current user’s Windows certificate store. To correct this, either disable signing of the ClickOnce manifest or install the certificate into the certificate store. 
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (2718): Cannot import the following key file: . The key file may be password protected. To correct this, try to import the certificate again or import the certificate manually into the current user’s personal certificate store. 
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (2718): Importing key file "les.pfx" was canceled. 

CERT는 가게에 가져올뿐만 아니라 .csproj과 같은 폴더에 .

enter image description here

enter image description here

어떤 아이디어

Here's the cert info and the Thumbprint matches what's in the .csproj file: 

enter image description here

내가 여기에 무엇을 누락 될 수 있을까?

답변

0

오류 메시지에 따르면 에이전트 컴퓨터의 개인 저장소로 인증서를 가져와야합니다. 개인 저장소에서 인증서를 참조하면 암호를 묻지 않으므로 코드 서명 인증서에 액세스 할 수 있습니다.

ClickOnce로 여러 프로젝트를 빌드하는 경우 각 프로젝트에 인증서를 가져와야합니다.

빌드 에이전트 시스템에서 인증서를 가져 Visual Studio 명령 프롬프트를 사용 해보세요 :

  1. 시작> 모든 프로그램> 마이크로 소프트 비주얼 스튜디오> 비주얼 스튜디오 도구> 비주얼 스튜디오 명령 프롬프트를.
  2. 다음 명령을 입력 샘플 :

    sn -i "c:\Pathtofile\.pfx" VS_KEY_C1D3ACB8FBF1AGK4

    참고 : -i 매개 변수와 함께 Sn.exe를이라는 이름의 키 컨테이너에에서 키 쌍을 설치합니다.

  3. Visual Studio로 pfx 파일을 다시 가져옵니다.

또한 PowerShell 스크립트를 만들려고하고 인증서를 가져 빌드 정의에 pre-build scripts를 실행할 수 있습니다. 참조 용

PowerShell을 스크립트 샘플 :

$pfxpath = 'pathtoees.pfx' 
$password = 'password' 

Add-Type -AssemblyName System.Security 
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 
$cert.Import($pfxpath, $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet") 
$store = new-object system.security.cryptography.X509Certificates.X509Store -argumentlist "MY", CurrentUser 
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite") 
$store.Add($cert) 
$store.Close() 

참조 이러한 스레드 :

관련 문제