Skip to content

Commit f2204a0

Browse files
Ryan HutchisonTravisEz13
andauthored
Authenticode https fix issue PowerShell#12827 (PowerShell#16134)
* Added https:// as valid prefix for TSA url * fixed typo * Format matching * Added proper logic * Appended https to error message * Update src/System.Management.Automation/security/Authenticode.cs I agree. Co-authored-by: Travis Plunk <[email protected]> Co-authored-by: Travis Plunk <[email protected]>
1 parent ebfb62b commit f2204a0

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/Microsoft.PowerShell.Security/resources/SignatureCommands.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
<value>Cannot sign code. The specified certificate is not suitable for code signing.</value>
122122
</data>
123123
<data name="TimeStampUrlRequired" xml:space="preserve">
124-
<value>Cannot sign code. The TimeStamp server URL must be fully qualified in the form of http://&lt;server url&gt;</value>
124+
<value>Cannot sign code. The TimeStamp server URL must be fully qualified in the form of http://&lt;server url&gt; or https://&lt;server url&gt;.</value>
125125
</data>
126126
<data name="CannotRetrieveFromContainer" xml:space="preserve">
127127
<value>The Get-AuthenticodeSignature cmdlet does not support directories. Supply a path to a file and retry.</value>

src/System.Management.Automation/resources/Authenticode.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
<value>Cannot sign code. The specified certificate is not suitable for code signing.</value>
143143
</data>
144144
<data name="TimeStampUrlRequired" xml:space="preserve">
145-
<value>Cannot sign code. The TimeStamp server URL must be fully qualified, and in the format http://&lt;server url&gt;.</value>
145+
<value>Cannot sign code. The TimeStamp server URL must be fully qualified, and in the format http://&lt;server url&gt; or https://&lt;server url&gt;.</value>
146146
</data>
147147
<data name="InvalidHashAlgorithm" xml:space="preserve">
148148
<value>Cannot sign code. The hash algorithm is not supported.</value>

src/System.Management.Automation/security/Authenticode.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@ internal static Signature SignFile(SigningOption option,
109109
Utils.CheckArgForNullOrEmpty(fileName, "fileName");
110110
Utils.CheckArgForNull(certificate, "certificate");
111111

112-
// If given, TimeStamp server URLs must begin with http://
112+
// If given, TimeStamp server URLs must begin with http:// or https://
113113
if (!string.IsNullOrEmpty(timeStampServerUrl))
114114
{
115-
if ((timeStampServerUrl.Length <= 7) ||
116-
(timeStampServerUrl.IndexOf("http://", StringComparison.OrdinalIgnoreCase) != 0))
115+
if ((timeStampServerUrl.Length <= 7) || (
116+
(timeStampServerUrl.IndexOf("http://", StringComparison.OrdinalIgnoreCase) != 0) &&
117+
(timeStampServerUrl.IndexOf("https://", StringComparison.OrdinalIgnoreCase) != 0)))
117118
{
118119
throw PSTraceSource.NewArgumentException(
119120
nameof(certificate),

0 commit comments

Comments
 (0)