Forums

ASGI and tls/ssl for a custom domain

Hello

Using the page on asgi api and pa_install_webapp_ssl.py from http custom certs, I'm trying to get a fastAPI app running for a custom domain with a custom cert. But I get the error

POST to set SSL details via API failed, got <Response [403]>:{"detail":"You do not have permission to perform this action."}

(same error for pa webapp install-ssl as well)

This is from a bash shell with no venv active and after the custom domain has been configured. I've also already had the fastAPI app up working on the user.pythonanywhere.com without issue and on the custom site without the custom cert without issue.

I've also managed to get the site to work temporarily by setting up the custom domain with the custom cert in the web interface, then deleting the domain and recreating it with the api, but it will only work for a few minutes before it give the cert mismatch error.

Am I missing a step to get pa_install_webapp_ssl.py to install the custom cert as expected?

Thanks for your help

You cannot, at present, set a certificate on a fastAPI website on a custom domain.

Is there a work around available? It seems like it should be something doable as uvicorn can handle the certs itself.

/home/{user}/.virtualenvse/{web_project}/bin/uvicorn

--uds $DOMAIN_SOCKET --ssl-certfile={ssl_cert_path}

--ssl-keyfile={ssl_key_path} main:app

The only issue is the existing letsencrypt cert gets in the way and is used instead of the specified certificate.

Email us at support@pythonanywhere.com and we will see if we can help you with a cert.