Logstash throws out 'Host name does not match the certificate subject provided by the peer' error

Able to solve this issue by making the below change to output.

    output {
          elasticsearch {
            hosts => ["https://node1.elasticsearch.com:9200", "https://node2.elasticsearch.com:9200", "https://node3.elasticsearch.com:9200"]
                user => "logstash_writer"
                password => "changeme"
                ssl_certificate_verification => false
                cacert => "/opt/elk/logstash-7.12.0/config/elasticsearch-ca.pem"
           }
            stdout { codec => rubydebug }
        }

I included ssl_certificate_verification => false to solve the issue, but without that, it is impossible to go past the error.

Is there any way to solve this issue without disabling certificate verification?