~ubuntu-branches/ubuntu/trusty/nodejs/trusty-proposed

« back to all changes in this revision

Viewing changes to src/node_crypto.cc

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-12-12 23:04:07 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20131212230407-xfa6gka4c6oatsx1
Tags: 0.10.23~dfsg1-1
* Upstream update.
* Refresh patches, remove 1005 patch, applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1022
1022
  NODE_SET_PROTOTYPE_METHOD(t, "getCurrentCipher", Connection::GetCurrentCipher);
1023
1023
  NODE_SET_PROTOTYPE_METHOD(t, "start", Connection::Start);
1024
1024
  NODE_SET_PROTOTYPE_METHOD(t, "shutdown", Connection::Shutdown);
1025
 
  NODE_SET_PROTOTYPE_METHOD(t, "receivedShutdown", Connection::ReceivedShutdown);
1026
1025
  NODE_SET_PROTOTYPE_METHOD(t, "close", Connection::Close);
1027
1026
 
1028
1027
#ifdef OPENSSL_NPN_NEGOTIATED
1189
1188
        p->sniContext_ = Persistent<Value>::New(ret);
1190
1189
        SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(
1191
1190
                                Local<Object>::Cast(ret));
 
1191
        p->InitNPN(sc, true);
1192
1192
        SSL_set_SSL_CTX(s, sc->ctx_);
1193
1193
      } else {
1194
1194
        return SSL_TLSEXT_ERR_NOACK;
1223
1223
 
1224
1224
  if (is_server) SSL_set_info_callback(p->ssl_, SSLInfoCallback);
1225
1225
 
1226
 
#ifdef OPENSSL_NPN_NEGOTIATED
1227
 
  if (is_server) {
1228
 
    // Server should advertise NPN protocols
1229
 
    SSL_CTX_set_next_protos_advertised_cb(sc->ctx_,
1230
 
                                          AdvertiseNextProtoCallback_,
1231
 
                                          NULL);
1232
 
  } else {
1233
 
    // Client should select protocol from advertised
1234
 
    // If server supports NPN
1235
 
    SSL_CTX_set_next_proto_select_cb(sc->ctx_,
1236
 
                                     SelectNextProtoCallback_,
1237
 
                                     NULL);
1238
 
  }
1239
 
#endif
 
1226
  p->InitNPN(sc, is_server);
1240
1227
 
1241
1228
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
1242
1229
  if (is_server) {
1778
1765
}
1779
1766
 
1780
1767
 
1781
 
Handle<Value> Connection::ReceivedShutdown(const Arguments& args) {
1782
 
  HandleScope scope;
1783
 
 
1784
 
  Connection *ss = Connection::Unwrap(args);
1785
 
 
1786
 
  if (ss->ssl_ == NULL) return False();
1787
 
  int r = SSL_get_shutdown(ss->ssl_);
1788
 
 
1789
 
  if (r & SSL_RECEIVED_SHUTDOWN) return True();
1790
 
 
1791
 
  return False();
1792
 
}
1793
 
 
1794
 
 
1795
1768
Handle<Value> Connection::IsInitFinished(const Arguments& args) {
1796
1769
  HandleScope scope;
1797
1770
 
1980
1953
  return True();
1981
1954
}
1982
1955
 
 
1956
 
 
1957
void Connection::InitNPN(SecureContext* sc, bool is_server) {
 
1958
#ifdef OPENSSL_NPN_NEGOTIATED
 
1959
  if (is_server) {
 
1960
    // Server should advertise NPN protocols
 
1961
    SSL_CTX_set_next_protos_advertised_cb(sc->ctx_,
 
1962
                                          AdvertiseNextProtoCallback_,
 
1963
                                          NULL);
 
1964
  } else {
 
1965
    // Client should select protocol from advertised
 
1966
    // If server supports NPN
 
1967
    SSL_CTX_set_next_proto_select_cb(sc->ctx_,
 
1968
                                     SelectNextProtoCallback_,
 
1969
                                     NULL);
 
1970
  }
 
1971
#endif
 
1972
}
 
1973
 
1983
1974
#ifdef OPENSSL_NPN_NEGOTIATED
1984
1975
Handle<Value> Connection::GetNegotiatedProto(const Arguments& args) {
1985
1976
  HandleScope scope;