A brush with the law

A brief encounter or experience with the police because of a crime.

The man had a brush with the law when he was young but now he is totally honest.