brush with the law

(have) a brush with the law (a brief encounter or experience with the police because of a crime) — cтычка с законом, столкновение с законом, нелады с законом

Example: He had two brushes with (the) law when he was young but now he is totally honest.

Usually used when talking about minor legal offences