< Summary - Kestrun — Combined Coverage

Information
Class: Public.Certificate.Import-KrCertificate
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Certificate/Import-KrCertificate.ps1
Tag: Kestrun/Kestrun@5f1d2b981c9d7292c11fd448428c6ab6c811c5de
Line coverage
71%
Covered lines: 5
Uncovered lines: 2
Coverable lines: 7
Total lines: 43
Line coverage: 71.4%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 11/19/2025 - 17:40:50 Line coverage: 0% (0/7) Total lines: 38 Tag: Kestrun/Kestrun@fcf33342333cef0516fe0d0912a86709874fd02601/21/2026 - 17:07:46 Line coverage: 71.4% (5/7) Total lines: 38 Tag: Kestrun/Kestrun@3f6f61710c7ef7d5953cab578fe699c1e5e01a3604/19/2026 - 15:52:57 Line coverage: 71.4% (5/7) Total lines: 43 Tag: Kestrun/Kestrun@765a8f13c573c01494250a29d6392b6037f087c9

Coverage delta

Coverage delta 72 -72

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Certificate/Import-KrCertificate.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Imports a PFX/PEM certificate file and returns X509Certificate2.
 4    .DESCRIPTION
 5        The Import-KrCertificate function allows you to import a certificate into the Kestrun environment.
 6        This may include loading a certificate from a file or other source and adding it to the appropriate certificate 
 7    .PARAMETER FilePath
 8        The path to the certificate file to import.
 9    .PARAMETER Password
 10        The password for the certificate file, if applicable.
 11    .PARAMETER PrivateKeyPath
 12        The path to the private key file, if applicable.
 13    .EXAMPLE
 14        Import-KrCertificate -Path "C:\certs\mycert.pfx" -Password (ConvertTo-SecureString "password" -AsPlainText -Forc
 15        This example imports a certificate from the specified path using the provided password.
 16    .NOTES
 17        This function is part of the Kestrun PowerShell module.
 18#>
 19function Import-KrCertificate {
 20    [KestrunRuntimeApi('Everywhere')]
 21    [CmdletBinding()]
 22    [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2])]
 23    param(
 24        [Parameter(Mandatory)]
 25        [string]$FilePath,
 26
 27        [Parameter()]
 28        [securestring]$Password,
 29
 30        [Parameter()]
 31        [string]$PrivateKeyPath
 32    )
 133    $resolvedPath = Resolve-KrPath -Path $FilePath -KestrunRoot -Test
 134    Write-KrLog -Level Verbose -Message "Resolved file path: $resolvedPath"
 235    if ( -not (Test-Path -Path $resolvedPath -PathType Leaf)) {
 036        throw "Certificate file not found at path: $resolvedPath"
 37    }
 138    if ($null -eq $Password) {
 039        return [Kestrun.Certificates.CertificateManager]::Import($resolvedPath, $PrivateKeyPath)
 40    }
 141    return [Kestrun.Certificates.CertificateManager]::Import($resolvedPath, $Password, $PrivateKeyPath)
 42}
 43

Methods/Properties

Import-KrCertificate()