Generally, a free confession to police isn't inherently unlawful, but its acceptance in a trial is a tricky matter. The key factor is whether it was obtained fairly. Police must adhere to specific rules, including https://panchanandshaw.com/blog/contempt-law-guide/