This may be regarded as an invasion of privacy - and therefore against the law. However, you maybe able to argue that what you are really recording is your own voice - and the witness's voice s secondary. Why would you want to record your own voice ? - because you expected that the witness would later claim you were aggressive and that you lied. Consequently, you wished to prepare your defence..
The simple way of doing this is to carry a small cassette record ( a dictation machine) in a top pocket where the microphone points upwards towards your face. Some MP3 players have recording facility - and these may be used too. Microphones on wires are not a good idea - it looks too much like bugging and a clear invasion of privacy.
If you use the cassette system, remember that the maximum length of time of the tape. At the end it will click - and perhaps the witness will hear it. So at around that time, take out a retractable ball pen - and start to click the end absentmindedly whilst you offer to give the witness your contact details.
For the above reasons, it is wise to keep surreptitious recordings very secret. Do not even tell the solicitor unless you can trust him or her. Certainly never tell the prisoner - this is exactly the juicy kid of news that will spread round the prison like wildfire - and have you quickly into the police station.