I highly doubt there are any real "friends" when you get to that level of LCN. Gallo probably just had a good working relationship with Castellano but was smart enough to see that Gotti etc were coming and it was better to let them do their thing than start a war.

I don't think he was caught up in the Commission trial because they didn't catch him in any of the specific conspiracies they were charging the guys with. He was charged in the Gambino Family case that stemmed from the bug in Castellano's house.