WinRM (HTTPS) destination computer returned an 'access denied' error

I just enabled WinRM service in my Windows 10 machine (Home edition - no group policy) for HTTPS. I first created a self signing test certificate through powershell and started a WinRM listener (port 5986, which is allowed in Firewall).

I wanted to test it in the same machine if I can start an interactive session through the following commands (with administrative rights):

$so = New-PsSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$sess = New-PSSession -ComputerName 127.0.0.1 -UseSSL -SessionOption $so -CertificateThumbprint "14FEDEADE9785547C4C0EC986D42D0EF795BBA0C"
Enter-PSSession -Session $sess  

However I get the following error:

WinRM client cannot process the request. The destination computer (127.0.0.1:5986) returned an 'access denied'
error. Specify one of the authentication mechanisms supported by the server. If Kerberos mechanism is used, verify
that the client computer and the destination computer are joined to a domain. Possible authentication mechanisms
reported by server: Basic   Negotiate   ClientCerts For more information, see the about_Remote_Troubleshooting Help
topic.

I also tried the Ruby library for Windows Remote Management using the private key and certificate extracted from the .pfx file (on another computer in the network), but I get a WinRM::WinRMAuthorizationError.

Here is the winrm get winrm/config output:

Config
    MaxEnvelopeSizekb = 500
    MaxTimeoutms = 60000
    MaxBatchItems = 32000
    MaxProviderRequests = 4294967295
    Client
        NetworkDelayms = 5000
        URLPrefix = wsman
        AllowUnencrypted = false
        Auth
            Basic = true
            Digest = true
            Kerberos = false
            Negotiate = true
            Certificate = true
            CredSSP = false
        DefaultPorts
            HTTP = 5985
            HTTPS = 5986
        TrustedHosts = *
    Service
        RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)(A;;GR;;;IU)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
        MaxConcurrentOperations = 4294967295
        MaxConcurrentOperationsPerUser = 1500
        EnumerationTimeoutms = 240000
        MaxConnections = 300
        MaxPacketRetrievalTimeSeconds = 120
        AllowUnencrypted = false
        Auth
            Basic = true
            Kerberos = true
            Negotiate = true
            Certificate = true
            CredSSP = false
            CbtHardeningLevel = Relaxed
        DefaultPorts
            HTTP = 5985
            HTTPS = 5986
        IPv4Filter = *
        IPv6Filter = *
        EnableCompatibilityHttpListener = false
        EnableCompatibilityHttpsListener = false
        CertificateThumbprint
        AllowRemoteAccess = true
    Winrs
        AllowRemoteShellAccess = true
        IdleTimeout = 7200000
        MaxConcurrentUsers = 2147483647
        MaxShellRunTime = 2147483647
        MaxProcessesPerShell = 2147483647
        MaxMemoryPerShellMB = 2147483647
        MaxShellsPerUser = 2147483647

[Edit]: I just tried from another Windows 10 computer, this time the error is different:

New-PSSession : [192.168.0.29] Connecting to remote server 192.168.0.29 failed with the following error message : The server certificate 
on the destination computer (192.168.0.29:5986) has the following errors:      
The SSL certificate is expired. For more information, see the about_Remote_Troubleshooting Help topic.

Which is really weird because the certificate is valid until 2020 (so that the error message is not true).


Solution 1:

Sometimes troubles with WinRM and "Access denied" were caused by an invalid certificates configuration.
The details can be found here at Microsoft.