Pode.Web icon indicating copy to clipboard operation
Pode.Web copied to clipboard

No client certificate supplied - 401

Open CharEmMech opened this issue 1 year ago • 2 comments

Question

Any clue what I'm doing wrong here? I generated a new certificate with powershell, gave it a friendlyname, and added it to localmachine\my and also added it to trusted store.

No matter what I get 401 error. Using Edge browser and have tried with powershell 5.1 and 7.4.2

`Import-Module -name pode, pode.web

Start-PodeServer -Threads 8 {

Add-PodeEndpoint -Address '192.168.0.55' -Port 443 -Protocol Https -CertificateName 'hotdog' -CertificateStoreLocation 'LocalMachine' -CertificateStoreName 'My' -AllowClientCertificate 

New-PodeAuthScheme -ClientCertificate | Add-PodeAuth -Name 'CertLogin' -Sessionless -ScriptBlock {

    param($cert, $errors)
   
    if ($cert.Thumbprint -eq '') {
        return @{
            User = @{
                ID ='M0R7Y302'
                Name = 'Morty'
                Type = 'Human'
            }
        }
    }

    # an invalid cert
    return @{ Message = 'Invalid certificate supplied' }
}

Add-PodeAuthMiddleware -Name 'GlobalAuthValidation' -Authentication 'CertLogin'

Use-PodeWebTemplates -Title "test" -Theme Light

Add-PodeWebPage -Name 'Test' -Icon 'Settings'  -ScriptBlock {
    New-PodeWebCard -Content @(
        New-PodeWebTable -Name 'Accounts' -CsvFilePath "C:\somedata.csv"
    )
}

}`

CharEmMech avatar Jun 06 '24 20:06 CharEmMech

Hi @CharEmMech,

Is this line:

if ($cert.Thumbprint -eq '') {

meant to be the following instead? as the above will throw a 401 if the cert has a thumbprint

if ($cert.Thumbprint -ne '') {

Badgerati avatar Jun 06 '24 21:06 Badgerati

Thanks for the reply, I just omitted the thumbprint of the cert there. it should be -eq '12334566677788888' it does not work with a valid thumbprint in there.

CharEmMech avatar Jun 07 '24 12:06 CharEmMech