digipost / signature-api-client-dotnet

Apache License 2.0
3 stars 3 forks source link

Tips til problemløsning #396

Open talisker77 opened 2 years ago

talisker77 commented 2 years ago

Tips til problemløsning

Når vi opplever problemer rundt tilkobling, og får feil som f.eks:

Finnes det noen enkle former for problemløsningsmetoder som kan rydde vekk støy fra dotnet klienten?

Lagde et powershell skript:

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
[System.Net.ServicePointManager]::Expect100Continue=$true
[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.SecurityProtocolType]::Tls12
#invoke-get-status.ps1
$orgNummer = "orgnr" #org nummer
$queueName = "kø-navn" 
$isProd = $false # $true/$false
if ($isProd) {
    $baseUrl = "https://api.signering.posten.no"
}
else {
    $baseUrl = "https://api.difitest.signering.posten.no"
}

$requestUrl = "$($baseUrl)/api/$($orgNummer)/portal/signature-jobs?polling_queue=$($queueName)"

write-host $requestUrl
$thumb = 'thumb lagret i store'
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store([System.Security.Cryptography.X509Certificates.StoreName]::My, [System.Security.Cryptography.X509Certificates.StoreLocation]::LocalMachine)
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadOnly);
$cert = $store.Certificates.Find([System.Security.Cryptography.X509Certificates.X509FindType]::FindByThumbprint, $thumb, $false)
$store.Close()
Write-Host $cert[0]
#$response = 
$headers = @{
    'Accept' = 'application/xml'
}
try {
    Invoke-RestMethod -Uri $requestUrl -Certificate $cert[0] -Method Get -Headers $headers #-Proxy 'http://localhost:8888'
}
catch {
    # Dig into the exception to get the Response details.
    # Note that value__ is not a typo.
    Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__ 
    Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription

    Write-Host "InnerException.Message:" $_.Exception.InnerException.Message
    Write-Host "InnerException.InnerException.Message:" $_.Exception.InnerException.InnerException.Message
}
#Write-Host ($response | ConvertTo-Json -Depth 10)

Når en kjører denne får vi bare feil, hadde forventet 200 med innhold (med NoChanges):

InnerException.Message: Authentication failed, see inner exception.
InnerException.InnerException.Message: The credentials supplied to the package were not recognized

Noen andre metoder for å enkelt kunne etablere problemer rundt brannmur,proxy,sertifikat, osv?