HewlettPackard / POSH-HPEOneView

PowerShell language bindings library for HPE OneView.
http://hewlettpackard.github.io/POSH-HPEOneView/
125 stars 52 forks source link

`Get-OVserver -name $server | Get-OVIloSso -IloRestSession` returns Exception calling "GetResponse" with "0" argument(s): "The SSL connection could not be established, see inner exception #669

Open aderusha opened 7 months ago

aderusha commented 7 months ago

Get-OVIloSso returns Exception calling "GetResponse" with "0" argument(s): "The SSL connection could not be established, see inner exception."

This problem was originally opened as #614 and then marked closed complete. The problem still exists in PowerShell 7.0+

Expected Behavior

An SSO token should be returned, even against self-signed iLOs, and should work in PowerShell 7 like it does in PowerShell 5.

Actual Behavior

Powershell 5 works as expected, Powershell 7 returns:

Exception calling "GetResponse" with "0" argument(s): "The SSL connection could not| be established, see inner exception."

Steps to reproduce

Get-OVserver -name $server | Get-OVIloSso -IloRestSession -Verbose
VERBOSE: [GET-OVILOSSO] Bound PS Parameters: 
Key            Value
---            -----
IloRestSession True
Verbose        True

VERBOSE: [GET-OVILOSSO] Called from: <ScriptBlock>
VERBOSE: [GET-OVILOSSO] Server Hardware was provided.
VERBOSE: [GET-OVILOSSO] Processing [*****REDACTED******], bay 1
VERBOSE: [SEND-OVREQUEST] BEGIN
VERBOSE: [SEND-OVREQUEST] Called from: Get-OVIloSso
VERBOSE: [SEND-OVREQUEST] Bound PS Parameters: 
Key      Value
---      -----
uri      /rest/server-hardware/35393350-3133-584D-5133-343430375736/iloSsoUrl
Hostname 10.1.2.3

VERBOSE: [SEND-OVREQUEST] Process
VERBOSE: [SEND-OVREQUEST] Hostname value: 
Name         ConnectionId
----         ------------
10.1.2.3            1

VERBOSE: [SEND-OVREQUEST] Filtering for Connection Object via PSObject: 
Name         ConnectionId
----         ------------
10.1.2.3            1

VERBOSE: [SEND-OVREQUEST] Processing '10.1.2.3' appliance connection request. 1 of 1
VERBOSE: [SEND-OVREQUEST] Requested URI '/rest/server-hardware/35393350-3133-584D-5133-343430375736/iloSsoUrl' to '10.1.2.3'
VERBOSE: [SEND-OVREQUEST] Restclient timeout setting: 20000
VERBOSE: [SEND-OVREQUEST] Request: GET https://10.1.2.3/rest/server-hardware/35393350-3133-584D-5133-343430375736/iloSsoUrl
VERBOSE: [SEND-OVREQUEST] Request Header 1: User-Agent = HPEOneView.PowerShell/8.50 (Microsoft Windows NT 10.0.14393.0)
VERBOSE: [SEND-OVREQUEST] Request Header 2: Content-Type = application/json
VERBOSE: [SEND-OVREQUEST] Request Header 3: Accept = application/json, text/html, application/xhtml+xml
VERBOSE: [SEND-OVREQUEST] Request Header 4: X-API-Version = 5600
VERBOSE: [SEND-OVREQUEST] Request Header 5: accept-language = en_US
VERBOSE: [SEND-OVREQUEST] Request Header 6: accept-encoding = gzip, deflate
VERBOSE: [SEND-OVREQUEST] Request Header 7: auth = [*****REDACTED******]
VERBOSE: [SEND-OVREQUEST] Response time: 00:00:00.7872814
VERBOSE: [SEND-OVREQUEST] Response Status: 200 (OK)
VERBOSE: [SEND-OVREQUEST] Response Header 1: Date = Wed, 07 Feb 2024 17:20:15 GMT
VERBOSE: [SEND-OVREQUEST] Response Header 2: Server = Apache
VERBOSE: [SEND-OVREQUEST] Response Header 3: Cache-Control = no-cache
VERBOSE: [SEND-OVREQUEST] Response Header 4: Pragma = no-cache
VERBOSE: [SEND-OVREQUEST] Response Header 5: X-XSS-Protection = 1; mode=block
VERBOSE: [SEND-OVREQUEST] Response Header 6: X-Frame-Options = DENY
VERBOSE: [SEND-OVREQUEST] Response Header 7: X-Content-Type-Options = nosniff
VERBOSE: [SEND-OVREQUEST] Response Header 8: Strict-Transport-Security = max-age=31536000
VERBOSE: [SEND-OVREQUEST] Response Header 9: Content-Security-Policy = default-src 'self' data: 'unsafe-inline' 'unsafe-eval' https://www.google-analytics.com https://www.hpe.com; font-src 'self' https://hpefonts.s3.amazonaws.com https://fonts.gstatic.com;
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
VERBOSE: [SEND-OVREQUEST] Response Header 10: Keep-Alive = timeout=15, max=100
VERBOSE: [SEND-OVREQUEST] Response Header 11: Connection = Keep-Alive
VERBOSE: [SEND-OVREQUEST] Response Header 12: Transfer-Encoding = chunked
VERBOSE: [SEND-OVREQUEST] Response Header 13: Content-Type = application/json; charset=utf-8
VERBOSE: [SEND-OVREQUEST] Response Header 14: Expires = 0
VERBOSE: [SEND-OVREQUEST] FinalResponse: {"iloSsoUrl":"https://10.4.5.6:443/Proxy/SSO?TKN=[*****REDACTED******]&HA=SHA384&KEY=ssononce [*****REDACTED******]&XE=dmvdisyncp01.deaconess.com&UN=ostadmin&UA=4&URL=https://10.4.5.6:443"}
VERBOSE: [SEND-OVREQUEST] Manual Pagination: False
VERBOSE: [SEND-OVREQUEST] Response object, no paging needed.
VERBOSE: [SEND-OVREQUEST] Cleaning up HttpWebRequest
VERBOSE: [SEND-OVREQUEST] Does nextPageUri member exist: False
VERBOSE: [SEND-OVREQUEST] Is nextPageUri Null or Empty: True
VERBOSE: [SEND-OVREQUEST] Stopping Do/Until loop because nextPageUri doesn't exist and have received all objects.
VERBOSE: [SEND-OVREQUEST] End
VERBOSE: [GET-OVILOSSO] Generating and returning iLO REST/RedFish SSO Session object
VERBOSE: [GET-OVILOSSO] Getting Redfish SessionID token from iLO, 10.4.5.6.
Get-OVIloSso: Exception calling "GetResponse" with "0" argument(s): "The SSL connection could not be established, see inner exception."

$> $Error[0].Exception.InnerException

Status         : UnknownError
Response       : 
TargetSite     : System.Net.WebResponse GetResponse()
Message        : The SSL connection could not be established, see inner exception.
Data           : {}
InnerException : System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
                  ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemoteCertificateChainErrors
                    at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions)
                    at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken)
                    at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
                    --- End of inner exception stack trace ---
                    at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
                    at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
                    at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
                    at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem)
                    at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellation(CancellationToken cancellationToken)
                    at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
                    at System.Net.Http.HttpMessageHandlerStage.Send(HttpRequestMessage request, CancellationToken cancellationToken)
                    at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
                    at System.Net.Http.HttpMessageHandlerStage.Send(HttpRequestMessage request, CancellationToken cancellationToken)
                    at System.Net.Http.Metrics.MetricsHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
                    at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
                    at System.Net.Http.HttpMessageHandlerStage.Send(HttpRequestMessage request, CancellationToken cancellationToken)
                    at System.Net.Http.SocketsHttpHandler.Send(HttpRequestMessage request, CancellationToken cancellationToken)
                    at System.Net.Http.HttpClient.Send(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
                    at System.Net.HttpWebRequest.SendRequest(Boolean async)
                    at System.Net.HttpWebRequest.GetResponse()
HelpLink       : 
Source         : System.Net.Requests
HResult        : -2146233087
StackTrace     :    at System.Net.HttpWebRequest.GetResponse()
                    at CallSite.Target(Closure, CallSite, HttpWebRequest)

Version Information

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Microsoft Windows 10.0.14393
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

$> Get-Module HPEOneView.850

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     8.50.3667…            HPEOneView.850                      {Add-OVApplianceTrustedCertificate, Add-OVBaseline, Add-OVClusterManager, Add-OVClusterNode…}

$> Get-OVVersion
10.1.2.3                        LibraryVersion Path
------------                        -------------- ----
ApplianceVersion: 8.60.01.485169.00 8.50.3667.2043 C:\Program Files\WindowsPowerShell\Modules\HPEOneView.850\8.50.3667.2043
danthomasbbc commented 4 months ago

+1 for this behaviour



Get-OVVersion

#####################      LibraryVersion Path
----------------------------        -------------- ----
ApplianceVersion: 8.70.00.486025.00 8.50.3667.2043 C:\Program Files\WindowsPowerShell\Modules\HPEOneView.850\8.50.3667.2043`

`$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0`