Consent can be a defense to alleged criminal conduct, i.e. rape, in certain cases in Pennsylvania if the consent meets specific elements.

Consent is a defense if the consent negates an element of the offense or precludes the infliction of the harm or evil sought to be prevented by the law defining the offense.

Consent is specifically a defense in cases involving bodily injury, i.e. assault cases, when the conduct charged to constitute an offense because it causes or threatens bodily injury, consent to such conduct or to the infliction of such injury is a defense if:

the conduct and the injury are reasonably foreseeable hazards of joint participation in a lawful athletic contest or the consent establishes a justification for the conduct.