Sex & dilated.

I went to the dr today & I am 35 weeks. I’m 1/2 cm dilated. Can I have sex or will that cause infection?