diff --git a/lib/client.js b/lib/client.js
index <HASH>..<HASH> 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -260,10 +260,11 @@ Client.prototype.connect = function(cfg) {
     self.emit('error', err);
   });
 
-  if (typeof cfg.hostVerifier === 'function'
-      && ~crypto.getHashes().indexOf(cfg.hostHash)) {
-    var hashCb = cfg.hostVerifier,
-        hasher = crypto.createHash(cfg.hostHash);
+  if (typeof cfg.hostVerifier === 'function') {
+    if (HASHES.indexOf(cfg.hostHash) === -1)
+      throw new Error('Invalid host hash algorithm: ' + cfg.hostHash);
+    var hashCb = cfg.hostVerifier;
+    var hasher = crypto.createHash(cfg.hostHash);
     stream.once('fingerprint', function(key, verify) {
       hasher.update(key, 'binary');
       verify(hashCb(hasher.digest('hex')));
Client: use cached crypto hashes list