'"Failed to read TLS record (2)" connecting to office365 IMAP using Chilcat ActiveX

We used to have internal Exchange and connection worked. Now the Exchange server is migrated to Office365 cloud, and I cannot connect.

EXEC sp_OASetProperty @imap, 'SslProtocol', 'TLS 1.2 or higher'
EXEC sp_OASetProperty @imap, 'Ssl', '1'
EXEC sp_OASetProperty @imap, 'Port', '993'
EXEC sp_OAMethod @imap, 'Connect', @success OUT, 'outlook.office365.com'

Error text:

ChilkatLog:
  Connect_Imap:
    DllDate: Jul 24 2019
    ChilkatVersion: 9.5.0.79
    UnlockPrefix: THOMASIMAPMAILQ
    Architecture: Little Endian; 64-bit
    Language: ActiveX / x64
    VerboseLogging: 0
    connectInner:
      connectToImapServer:
        hostname: outlook.office365.com
        port: 993
        socket2Connect:
          connect2:
            connectImplicitSsl:
              clientHandshake:
                clientHandshake2:
                  readHandshakeMessages:
                    Failed to read TLS record (2)
                    tlsRec_msg: 0
                    msgLen: 29298
                    nReadNBytes: 0
                    status: 0
                  --readHandshakeMessages
                --clientHandshake2
              --clientHandshake
              Client handshake failed. (3)
            --connectImplicitSsl
            ConnectFailReason: 103
          --connect2
        --socket2Connect
        failReason: 0
      --connectToImapServer
      connect failed.
    --connectInner
    Failed.
  --Connect_Imap
--ChilkatLog

It seems that the first handshake is OK, but the second fails. Any ideas?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source