- gethostname(host, sizeof(host));
- sprintf((char *)chal, "<%u.%u@%s>", (uint32_t)random(), (uint32_t)time(NULL), host);
- if (!bnet_fsend(bs, "auth cram-md5 %s\n", chal)) {
+ if (!gethostname(host, sizeof(host))) {
+ bstrncpy(host, my_name, sizeof(host));
+ }
+ bsnprintf(chal, sizeof(chal), "<%u.%u@%s>", (uint32_t)random(), (uint32_t)time(NULL), host);
+ if (!bnet_fsend(bs, "auth cram-md5 %s ssl=%d\n", chal, ssl_need)) {
+ return 0;
+ }
+
+ if (!bnet_ssl_client(bs, password, ssl_need)) {