Pennsylvania law allows for consent as a defense to crimes in certain instances.  But, even actual consent can be deemed ineffective to raise a defense to certain crimes in other instances.  Under Pennsylvania law, consent can be ineffective if:

it is given by a person who is legally incapacitated to authorize the conduct charged to constitute the offense; it is given by a person who by reason of youth (i.e. statutory rape), mental disease or defect or intoxication is manifestly unable or known by the actor to be unable to make a reasonable judgment as to the nature or harmfulness of the conduct charged to constitute the offense; it is given by a person whose improvident consent is sought to be prevented by the law defining the offense; or it is induced by force, duress, or deception of a kind sought to be prevented by the law defining the offense.