How to fix "Error Acquiring Token" when connecting to exchange online?

Tanaka Kouki 0 Reputation points
2024-07-24T09:35:42.22+00:00

I recieved this error when trying to connect to exchange online using the command below. Can anyone suggest or give me any solutions to this error?

Command:

Connect-ExchangeOnline - Credential $Cred

Error Acquiring Token:

System.Net.Http.HttpRequestException: この要求の送信中にエラーが発生しました。 ---> System.Net.WebException: 接続が切断されました:SSL/TLSのセキュリティで保護されているチャネルに対する信頼関係を確立できませんでした。 ---> System.Security.Authentication.AuthenticationException: 検証プロシージャによると、リモート証明書は無効です。

(Translation of the Japanese version by Google translation)

SystemNetHttpHttpRequestException: An error occurred while sending this request ---> SystemNetWebException: The connection was terminated: Could not establish trust relationship for the SSL/TLS secure channel ---> SystemSecurityAuthenticationAuthenticationException: According to the validation procedure, the remote certificate is invalid

I also tried to add certification using the command below to solve the error but this one didn't work.

Command:

$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2

$cert.Import("path_to_certificate.cer")

[System.Security.Cryptography.X509Certificates.X509Store]::new("Root", "LocalMachine").Add($cert)

Microsoft Exchange Online
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Noah Ma-MSFT 2,725 Reputation points Microsoft Vendor
    2024-07-25T09:00:17.34+00:00

    Hi @Tanaka Kouki ,

    Thank you for posting to Microsoft Community.

    Based on your description, I understand there is an error when you connect to Exchange Online in PowerShell. For the error message, it could be related to certificates.

    Make sure your root certificates are up to date from the trusted authorities. If you use a self-signed certificate or a certificate from an internal CA, you need to trust that CA. You can import the CA certificate into the trusted root certificate store.

    Check proxy and firewall settings and ensure your firewall settings to allow connections from O365. For a list of IP addresses and URLs that are used by Exchange Online, see the Exchange Online section of Microsoft 365 URLs and IP addresses.

    Also, please refer the -Credential part of Connect-ExchangeOnline (ExchangePowerShell) | Microsoft Learn to check the command.

    If my answer is helpful to you, please mark it as the answer so that other users can refer to it. Thank you for your support and understanding.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.