Generally, a voluntary confession to police isn't immediately illegal, but its use in court is a tricky matter. The vital factor is whether it was obtained fairly. Police must adhere to specific procedures, including https://panchanandshaw.com/blog/court-receiver-appointment-explained/