Pode.Web
Pode.Web copied to clipboard
No client certificate supplied - 401
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"
)
}
}`
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 '') {
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.