(PUP-2189) Use locking when opening SSL files for writing

Failure to do this can cause corruptions of for example the CRL when
multiple workers try to write to it concurrently.