Generally, a uncoerced confession to officers isn't automatically illegal, but its use in court is a complex matter. The key factor is whether it was obtained fairly. Police must adhere to specific procedures, https://panchanandshaw.com/blog/contempt-of-court-explained/