Skip to content

Commit

Permalink
Tools version 6.0.190307.1402 - minor addition Test-IoTCerts (#316)
Browse files Browse the repository at this point in the history
* Adding Test Cert method

* Fix build error for missing conditional feature for SMBIOS_DEFAULT
  • Loading branch information
parameshbabu committed May 13, 2019
1 parent 4d1fd0d commit 52fa363
Show file tree
Hide file tree
Showing 4 changed files with 237 additions and 184 deletions.
8 changes: 4 additions & 4 deletions Tools/IoTCoreImaging/IoTCoreImaging.psd1
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 1/16/2019
# Generated on: 3/7/2019
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'IoTCoreImaging.psm1'

# Version number of this module.
ModuleVersion = '6.0.190116.1218'
ModuleVersion = '6.0.190307.1402'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -98,7 +98,7 @@ FunctionsToExport = 'New-IoTFIPPackage', 'New-IoTFFUImage', 'New-IoTCabPackage',
'Import-IoTCertificate', 'Add-IoTDeviceGuard', 'Add-IoTSecureBoot',
'Add-IoTBitLocker', 'New-IoTOEMCerts', 'Install-IoTOEMCerts',
'Add-IoTProductFeature', 'Remove-IoTProductFeature', 'Import-QCBSP',
'New-IoTInf2Cab'
'New-IoTInf2Cab', 'Test-IoTCerts'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
Expand All @@ -115,7 +115,7 @@ AliasesToExport = 'addenv', 'buildfm', 'buildimage', 'buildpkg', 'buildppkg', 'b
'newcommonpkg', 'newdrvpkg', 'newproduct', 'open-ws', 're-signcabs',
'retailsign', 'setenv', 'setsignature', 'setversion', 'signbinaries',
'tfids', 'tpkgs', 'verifyrecovery', 'newprovpkg', 'gwsproducts', 'gwsbsps',
'addfid', 'removefid', 'inf2cab'
'addfid', 'removefid', 'inf2cab', 'tcerts'

# DSC resources to export from this module
# DscResourcesToExport = @()
Expand Down
1 change: 1 addition & 0 deletions Tools/IoTCoreImaging/IoTCoreImaging.psm1
Expand Up @@ -46,6 +46,7 @@ New-Alias -Name 'buildppkg' -Value 'New-IoTProvisioningPackage'
New-Alias -Name 'convertpkg' -Value 'Convert-IoTPkg2Wm'
New-Alias -Name 'tfids' -Value 'Test-IoTFeatures'
New-Alias -Name 'tpkgs' -Value 'Test-IoTPackages'
New-Alias -Name 'tcerts' -Value 'Test-IoTCerts'
New-Alias -Name 'importcfg' -Value 'Import-IoTDUCConfig'
New-Alias -Name 'exportpkgs' -Value 'Export-IoTDUCCab'
New-Alias -Name 'exportidm' -Value 'Export-IoTDeviceModel'
Expand Down
53 changes: 53 additions & 0 deletions Tools/IoTCoreImaging/IoTTestCommands.ps1
Expand Up @@ -173,6 +173,59 @@ function Test-IoTSignature {
return $retval
}

function Test-IoTCerts {
<#
.SYNOPSIS
Checks if the certs in the workspace folder are all valid.
.DESCRIPTION
Checks if the certs in the workspace folder are all valid.
.INPUTS
None
.OUTPUTS
System.Boolean
True if the file is properly signed.
.EXAMPLE
$result = Test-IoTCerts
.NOTES
This verifies using the Test-Certificate.
.LINK
[Test-Certificate](https://docs.microsoft.com/powershell/module/pkiclient/test-certificate?view=win10-ps)
#>
[CmdletBinding()]
[OutputType([Boolean])]
Param
(

)
$retval = $true
$certs = Get-ChildItem -Path $env:SRC_DIR, $env:COMMON_DIR -File -Filter *.cer -Recurse | Foreach-Object {$_.FullName}
if ($null -eq $certs) {
Publish-Status "No certs found."
}
$certs = @($certs)

foreach ($cert in $certs) {
# X509Certificate2 object that will represent the certificate
$certobj = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2

# Imports the certificate from file to x509Certificate object
$certobj.Import($cert)
$ret = Test-Certificate $certobj -AllowUntrustedRoot
if (!$ret) {
$retval = $false
Publish-Error "$cert is invalid"
}
}

return $retval
}

function Add-IoTSignature {
<#
.SYNOPSIS
Expand Down

0 comments on commit 52fa363

Please sign in to comment.