How is it possible to trust a public key that can confirm a message's signature? Let's assume I am able to confirm a certain message's signature with a public key that seems to be from Alice.
So I should be sure that the sender of that message is really Alice. But what if I have a public key where I think it is from Alice but actually is not and it still can confirms the signature of the message I got. So I am thinking it is from Alice since I used a key that is published as Alice's Public Key just from somebody else and that can confirm a message's signature I got where I think it is from Alice.

How can I be sure that both the message and the public key are really from the person they are named to be from?

There might be some weird thinking mistake I did here so I'd be happy to get enlightened.

Tried to visualize it.



Thanks in advance.
I am not commenting for what purpose your are going to use public key and answer your main question:


  How is it possible to trust a public key ...?


This one of the most important questions in cryptography: key distribution. Here are some possible solutions:


You can for instance meet Alice and exchange keys personally (but it is applicable in rare real cases).
Or you can use some channel that you trust to exchange keys.
Or you use PKI. Namely some certification authority issues a certificate confirming that the public key belongs to a particular person. The advantage is, that you can exchange certificates also via insecure channel. But to use PKI you need of course trust particular certification authority.