Convert AnsibleUnsafeText to String
I believe this is due to non existing variable attribute.
Most likely chain_from_certificate1 and chain_from_certificate2 don't have stdout
Did you try debug by printing the variables?
With stdout:
Did this throw similar failure?
    - name: print variable
      debug:
        msg: &quot;{{ chain_from_certificate1.stdout }}&quot;

Without stdout:
What is output of this?
Will this print same output as of manually execute openssl x509 -issuer -noout -in Certiticate1?
    - name: print variable
      debug:
        msg: &quot;{{ chain_from_certificate1 }}&quot;

My assumption is that the script set the value of stdout in chain_from_certificate1 and chain_from_certificate2 rather than the stdout: &lt;value&gt;. Therefor stdout do not exist as attribute.
Or chain_from_certificate1 and chain_from_certificate2 contain another data structure.
The key is to print them out.