Fixed agent creation bug when using TLS.