In this piece of code, why write to a .tmp file then immediately rename it without any prior processing ?
The mv command will be an atomic operation, whereas the command preceding it probably won't be. You wouldn't want that pem file to be in an invalid state if some other command comes along and tries to use it. Skip Montanaro