Another issue might be connected to the credential file itself. Recently the Azure IoT Core has been migrating their Root Certificate Authority from the Baltimore CyberTrust Root to the newer DigiCert Global Root G2.
Always ensure to use the right Certificate Authority (CA) for Azure IoT Core which you want to connect to, and make sure that the received credential file was created with the correct CA as well.
In case the CA which was used to create the credential file is not the same the IoT Core uses, the connection will time out.