Make certificateChain() thread safe

Fixes #487, #491, #454