After enabling SSL, MySite errors in SharePoint 2016

After I enabled SSL on Mysite, I was not able to access https://mysite.contoso.com.

Errors:

Error when trying to access https://mysite.contoso.com

Server Error in ‘/’ Application.

The Web application at http://my.contoso.com/ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Event Log:
Log Name: Application
Source: ASP.NET 4.0.30319.0
Event ID: 1309
Task Category: Web Event
Level: Warning
Description:
Event code: 3005 Event message: An unhandled exception has occurred.
Event ID: b7c0df5f101e49ea917b0c7760909201 Event sequence: 8 Event occurrence: 2 Event detail code: 0 Application information: Application domain: /LM/W3SVC/1918574463/ROOT-3-131617109719382610 Trust level: Full Application Virtual Path: / Application Path: C:\inetpub\wwwroot\wss\VirtualDirectories\my.contoso.com80\ Machine name: SPCONTOSO Process information: Process ID: 5652 Process name: w3wp.exe Account name: CONTOSO\SPWebApps Exception information: Exception type: FileNotFoundException Exception message: The Web application at http://my.contoso.com/ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
at Microsoft.SharePoint.SPSite.LookupSiteInfo(SPFarm farm, Boolean contextSite, Boolean swapSchemeForPathBasedSites, Uri& requestUri, Boolean& lookupRequiredContext, Guid& applicationId, Guid& contentDatabaseId, Guid& siteId, Guid& siteSubscriptionId, SPUrlZone& zone, String& serverRelativeUrl, Boolean& hostHeaderIsSiteName, Boolean& appWebRequest, String& appHostHeaderRedirectDomain, String& appSiteDomainPrefix, String& subscriptionName, String& appSiteDomainId, Uri& primaryUri)

Resolution:

After enabling SSL for mysite, you have to change the following:
1. Change the default AAM (Alternate Accessing Mappings) to https://mysite.contoso.com
2. Modify the MySite settings in the User Profile Service:
a.  Go to CA -> Manage Service Applications->Click on User Profile Service->Click on Setup My Sites under My Site Settings

b. Modify the My Host Location URL to https://mysite.contoso.com:443 as show below and click OK to save