Пример #1
0
  /**
   * Extracts the relevant socket stuff and adds it to the request object. This method relies on the
   * base class for everything other than SSL related attributes
   */
  protected void parseSocketInfo(Socket socket, WinstoneRequest req) throws IOException {
    super.parseSocketInfo(socket, req);
    if (socket instanceof SSLSocket) {
      SSLSocket s = (SSLSocket) socket;
      SSLSession ss = s.getSession();
      if (ss != null) {
        Certificate certChain[] = null;
        try {
          certChain = ss.getPeerCertificates();
        } catch (Throwable err) {
          /* do nothing */
        }

        if (certChain != null) {
          req.setAttribute("javax.servlet.request.X509Certificate", certChain);
          req.setAttribute("javax.servlet.request.cipher_suite", ss.getCipherSuite());
          req.setAttribute("javax.servlet.request.ssl_session", new String(ss.getId()));
          req.setAttribute("javax.servlet.request.key_size", getKeySize(ss.getCipherSuite()));
        }
      }
      req.setIsSecure(true);
    }
  }