Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robin1985 add function for appending signature #1223

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions src/app/FakeLib/SignToolHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,47 @@ let Sign (toolsPath : string) (parameters : SignParams) (filesToSign : seq<strin

traceEndTask "SignTool" "Successfully signed the specified assemblies"


/// Appends a SHA 256 signature to assemblies according to the settings specified in the parameters using signtool.exe.
/// This will be looked up using the toolsPath parameter.
let AppendSignature (toolsPath : string) (parameters : SignParams) (filesToSign : seq<string>) =
traceStartTask "SignTool" "Trying to dual sign the specified assemblies"

let signPath = toolsPath @@ "signtool.exe"

let certToUse = match parameters.Certificate with
| Some cert -> if File.Exists cert.CertFile then cert else parameters.DevCertificate
| None -> parameters.DevCertificate

let baseCall = sprintf "sign /f \"%s\" /as /fd sha256 " certToUse.CertFile


let withTimeStamp = baseCall + match parameters.TimeStampUrl with
| Some url -> sprintf " /tr \"%s\" /td sha256" url.AbsoluteUri
| None -> ""

let withPassword = withTimeStamp + match certToUse.PasswordFile with
| Some pass -> sprintf " /p \"%s\"" (ReadLine pass)
| None -> ""


filesToSign
|> Seq.iter (fun fileToSign ->
let withFileToSign = withPassword + sprintf " \"%s\"" fileToSign

let result =
ExecProcess (fun info ->
info.FileName <- signPath
info.Arguments <- withFileToSign) System.TimeSpan.MaxValue
if result <> 0 then failwithf "Error during sign call ")

traceEndTask "SignTool" "Successfully dual signed the specified assemblies"

[<Obsolete>]
/// Signs all files in filesToSign with the certification file certFile,
/// protected with the password in the file passFile.
/// The signtool will be search in the toolPath.
[<Obsolete>]

let SignTool toolsPath certFile passFile filesToSign =
let certToUse = {
CertFile = certFile
Expand All @@ -78,4 +115,4 @@ let SignTool toolsPath certFile passFile filesToSign =
TimeStampUrl = None
}

Sign toolsPath signParams filesToSign
Sign toolsPath signParams filesToSign