SSL is not valid for www.domain.com

If your hostname is site.com then you have it right. And that seems to be the case.

It’s generally recommended that your site be at www.site.com and have the apex domain redirect to the www. What I would do is change your hostname to www.site.com and do it the other way around.

I think that it gives one certificate that is valid for both.