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

No client certificate supplied - 401 #580

Open
CharEmMech opened this issue Jun 6, 2024 · 2 comments
Open

No client certificate supplied - 401 #580

CharEmMech opened this issue Jun 6, 2024 · 2 comments
Labels
question ❔ Further information is requested

Comments

@CharEmMech
Copy link

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 CharEmMech added the question ❔ Further information is requested label Jun 6, 2024
@Badgerati
Copy link
Owner

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 '') {

@CharEmMech
Copy link
Author

CharEmMech commented Jun 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question ❔ Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants