nanu1nkk1k2n3nj12n3
nanu1nkk1k2n3nj12n3

Reputation: 1

Prototyping IMAP connection to outlook365 server using openssl

I am trying to test connection to Outlook365 IMAP server.

As I understood. The first step should be to obtain access_token using my client_id and client_secret.

I got it using Postman

access_token from Postman

Then, using this access token, I constructed base64 string

Using PHP:

base64_encode("user=" . $email . "\x01auth=Bearer " . $accessToken . "\x01\x01")

Finally, I used the result base64 string in openssl terminal.

Openssl version OpenSSL 3.4.0 22 Oct 2024 (Library: OpenSSL 3.4.0 22 Oct 2024)

> openssl s_client -connect outlook.office365.com:993

...
* OK The Microsoft Exchange IMAP4 service is ready.

> A01 AUTHENTICATE XOAUTH2 <base64 string from PHP script above>

( ~30-60s later )

* BYE Connection is closed. 13
SSL routines::unexpected eof while reading:ssl/record/rec_layer_s3.c:688

Is my authentication flow bad ? Does this error signalize something else entirely ?

Thank you for any advice

Upvotes: 0

Views: 37

Answers (1)

Max
Max

Reputation: 10985

You need to add “-crlf” to your command line to terminate your commands correctly. It’s waiting because it didn’t see that your command was finished.

openssl s_client -crlf -connect outlook.office365.com:993

Upvotes: 0

Related Questions