Confessing to a crime?

How does someone confess to a crime in a private agreement like a civil restraint but protect themselves from criminal charges? Can a confidentiality order help?
Confessing to a crime?
Post Opinion