Your tomato problem is "Blossom-End Rot", the symptoms as you have described in your post. It affects green or ripe tomatoes.
The first thing you need to do is to remove the damaged fruits so that the
plant's energy will go to the good fruits.
It is mainly caused by the
plants inability to utilize calcium from the soil. Calcium is available to the
plant only when the soil is evenly moist.
Tomatoes are heavy user of water. Water deeply at regular interval. To help keep soil moist, place 3-5 inches of mulch around the
plant. Avoid using high nitrogen fertilizers or fresh manure soil amendment. The manure can have high salt content.
If your water or soil has too much soil, water more thoroughly to help leach salts through soil.