       .then (keys) ->
         deferred1 = Promise.defer()
         keyOpPrivate = window.msCrypto.subtle.exportKey('pkcs8', keys.privateKey)
+        keyOpPrivate.onerror = ->
+          log.error('Failed to export RSA private key using IE web crypto')
         keyOpPrivate.oncomplete = ->
           return deferred1.resolve(Forge.util.createBuffer(keyOpPrivate.result))
         privateKeyPromise = deferred1.promise
 
         deferred2 = Promise.defer()
         keyOpPublic = window.msCrypto.subtle.exportKey('spki', keys.publicKey)
+        keyOpPublic.onerror = ->
+          log.error('Failed to export RSA public key using IE web crypto')
         keyOpPublic.oncomplete = ->
           return deferred2.resolve(Forge.util.createBuffer(keyOpPublic.result))
         publicKeyPromise = deferred2.promise

        window.crypto.subtle.generateKey( {
          name: 'RSA-OAEP'
          modulusLength: params.bits
          publicExponent: new Uint8Array([1, 0, 1]) # constants
          hash: { name: 'SHA-256' }
        }, true, ['encrypt', 'decrypt'])
      .then (keys) ->

          keyPair.publicKey  = publicKey
          return keyPair
        )

    # Generate public and private RSA keys
    # returns a Promise object with private and public keys in Forge buffer objects
    generateKeypair: ->
      if window.crypto?.subtle?
        params = { bits: RSA_KEY_SIZE, e: EXPONENT_BIG_INT }
        log.info('generating keypair', params)
        log.debug('using web crypto API to generate keypair')
        return @webCryptoGenerate(params)
      else if window.msCrypto?.subtle?
        params = { bits: RSA_KEY_SIZE, e: EXPONENT_BIG_INT }
        log.info('generating keypair', params)
        log.debug('using IE 11 web crypto API to generate keypair')
        return @ieWebCryptoGenerate(params)
      else
        params = { bits: RSA_KEY_SIZE, e: EXPONENT_NUM }
        log.info('generating keypair', params)
        log.debug('using Forge to generate keypair')
        return @forgeGenerate(params)

  return RsaKeyGenerator
