Free memory open ssl

Added memory releasing when necessary.