Program: 20459
Project: 20459
Buggy source:
/** 
 * The server has indicated that TLS negotiation can start. We now need to secure the existing plain connection and perform a handshake. This method won't return until the connection has finished the handshake or an error occured while securing the connection.
 * @throws Exception if an exception occurs.
 */
void proceedTLSReceived() throws Exception {
  SSLContext context=SSLContext.getInstance("String_Node_Str");
  KeyStore ks;
  KeyManager[] kms=null;
  PasswordCallback pcb=null;
  if (callbackHandler == null) {
    ks=null;
  }
 else {
    System.out.println("String_Node_Str" + configuration.getKeystoreType());
    if (configuration.getKeystoreType().equals("String_Node_Str")) {
      Provider p=new sun.security.pkcs11.SunPKCS11(configuration.getPKCSConfig());
      Security.addProvider(p);
      ks=KeyStore.getInstance("String_Node_Str",p);
      pcb=new PasswordCallback("String_Node_Str",false);
      callbackHandler.handle(new Callback[]{pcb});
      ks.load(null,pcb.getPassword());
    }
 else     if (configuration.getKeystoreType().equals("String_Node_Str")) {
      ks=KeyStore.getInstance("String_Node_Str","String_Node_Str");
      ks.load(null,null);
    }
 else {
      ks=KeyStore.getInstance(configuration.getKeystoreType());
      pcb=new PasswordCallback("String_Node_Str",false);
      callbackHandler.handle(new Callback[]{pcb});
      ks.load(new FileInputStream(configuration.getKeystorePath()),pcb.getPassword());
    }
    KeyManagerFactory kmf=KeyManagerFactory.getInstance("String_Node_Str");
    try {
      if (pcb == null) {
        kmf.init(ks,null);
      }
 else {
        kmf.init(ks,pcb.getPassword());
        pcb.clearPassword();
      }
      kms=kmf.getKeyManagers();
    }
 catch (    NullPointerException npe) {
      kms=null;
    }
  }
  context.init(kms,new javax.net.ssl.TrustManager[]{new ServerTrustManager(serviceName,configuration)},new java.security.SecureRandom());
  Socket plain=socket;
  socket=context.getSocketFactory().createSocket(plain,plain.getInetAddress().getHostName(),plain.getPort(),true);
  socket.setSoTimeout(0);
  socket.setKeepAlive(true);
  initReaderAndWriter();
  ((SSLSocket)socket).startHandshake();
  if (((SSLSocket)socket).getWantClientAuth()) {
    System.err.println("String_Node_Str");
  }
 else   if (((SSLSocket)socket).getNeedClientAuth()) {
    System.err.println("String_Node_Str");
  }
 else {
    System.err.println("String_Node_Str");
  }
  usingTLS=true;
  packetWriter.setWriter(writer);
  packetWriter.openStream();
}

Fixed version (ground truth):
/** 
 * The server has indicated that TLS negotiation can start. We now need to secure the existing plain connection and perform a handshake. This method won't return until the connection has finished the handshake or an error occured while securing the connection.
 * @throws Exception if an exception occurs.
 */
void proceedTLSReceived() throws Exception {
  SSLContext context=SSLContext.getInstance("String_Node_Str");
  KeyStore ks=null;
  KeyManager[] kms=null;
  PasswordCallback pcb=null;
  if (callbackHandler == null) {
    ks=null;
  }
 else {
    System.out.println("String_Node_Str" + configuration.getKeystoreType());
    if (configuration.getKeystoreType().equals("String_Node_Str")) {
      ks=null;
      pcb=null;
    }
 else     if (configuration.getKeystoreType().equals("String_Node_Str")) {
      Provider p=new sun.security.pkcs11.SunPKCS11(configuration.getPKCSConfig());
      Security.addProvider(p);
      ks=KeyStore.getInstance("String_Node_Str",p);
      pcb=new PasswordCallback("String_Node_Str",false);
      callbackHandler.handle(new Callback[]{pcb});
      ks.load(null,pcb.getPassword());
    }
 else     if (configuration.getKeystoreType().equals("String_Node_Str")) {
      ks=KeyStore.getInstance("String_Node_Str","String_Node_Str");
      ks.load(null,null);
    }
 else {
      ks=KeyStore.getInstance(configuration.getKeystoreType());
      try {
        ks.load(new FileInputStream(configuration.getKeystorePath()),pcb.getPassword());
        pcb=new PasswordCallback("String_Node_Str",false);
        callbackHandler.handle(new Callback[]{pcb});
      }
 catch (      Exception e) {
        ks=null;
        pcb=null;
      }
    }
    KeyManagerFactory kmf=KeyManagerFactory.getInstance("String_Node_Str");
    try {
      if (pcb == null) {
        kmf.init(ks,null);
      }
 else {
        kmf.init(ks,pcb.getPassword());
        pcb.clearPassword();
      }
      kms=kmf.getKeyManagers();
    }
 catch (    NullPointerException npe) {
      kms=null;
    }
  }
  context.init(kms,new javax.net.ssl.TrustManager[]{new ServerTrustManager(serviceName,configuration)},new java.security.SecureRandom());
  Socket plain=socket;
  socket=context.getSocketFactory().createSocket(plain,plain.getInetAddress().getHostName(),plain.getPort(),true);
  socket.setSoTimeout(0);
  socket.setKeepAlive(true);
  initReaderAndWriter();
  ((SSLSocket)socket).startHandshake();
  if (((SSLSocket)socket).getWantClientAuth()) {
    System.err.println("String_Node_Str");
  }
 else   if (((SSLSocket)socket).getNeedClientAuth()) {
    System.err.println("String_Node_Str");
  }
 else {
    System.err.println("String_Node_Str");
  }
  usingTLS=true;
  packetWriter.setWriter(writer);
  packetWriter.openStream();
}