How can I stop legionaires attacking me during a mission?
Check to see if you have a bounty, if you do you could try going to the hold capital which if i recall this one is in riften. if you pay off your bounty it may reset their attitude towards you. If that does not work however you could always reload a previous save if you have one.
Legate Rikke may also be tied to solitude so check to see if you can pay a bounty there.
Yield and pay your bounty, or, if you are Thane of the hold where you are wanted, you should be able to tell the guard to look the other way by pulling rank.
NOTE: This only works once.