Waterproof Window Caulk
I have had the occasion to replace the portlights and skylights on my Hunter Legend. The Product that I used was called Boatlife Caulk. I removed the skylights using a piece of music wire thru the joint held with a vicegrips on each side my Firstmate and I used a sawing action to remove the skylight. After cleaning the surface and washing the area with alcohol I taped off the area around both sides of the window seam, applied the caulk, inserted the window and after about 20 minutes removed the tape. This product is said to even work underwater. However it is expensive. $10.00 USD for a small tube and about $18.00 for the size that fits in a caulk gun. It comes in clear,white and black.
Now when I put her over and the rail is in the water we have no water intrusion.