Need help with infinitive

The only way to have a friend is to be one.

Would both "to have" and "to be" be the infinitives

Yes.