Who has legal custody rights until judges says different if the parents are not married he is on the birth certificate and is married to someone else?

If you were not married when the child arrived the legal custody lies with the mother. The father have to prove paternity in court before he can get his parental rights.