Yes, it could be a dirty sail switch and by tapping on the gas valve it may move enough to close the contacts.
Another thing is to look at the gas valve. Most have two coils that both need to operate the gas valve. Locate the four wires going to the valve. Should be two wires connected together going to ground and two wires connected together going to the circuit board. disconnect a set of wires and check the coils for continuity. Each coil should be very close to being the same resistance.
The furnace may need a good cleaning. Blowing out with compressed air will do wonders for getting dust and other debris.