代码之家  ›  专栏  ›  技术社区  ›  Ivan Mushketyk

(错误代码:ssl_error_rx_record_too_long)tomcat+openssl

  •  8
  • Ivan Mushketyk  · 技术社区  · 14 年前

    我正试图在我的Tomcat中启用SSL。 但当我启动Tomcat并转到 https://localhost:8443 我懂了

    An error occurred during a connection to localhost:8443.
    
    SSL received a record that exceeded the maximum permissible length.
    
    (Error code: ssl_error_rx_record_too_long)
    

    为此,我使用ca.sh生成私钥和这样的签名证书:

    progerlaptop:/usr/share/ssl/misc # ./CA.sh -newca
    CA certificate filename (or enter to create)
    
    Making CA certificate ...
    Generating a 1024 bit RSA private key
    ................................++++++
    .............................................++++++
    writing new private key to './demoCA/private/./cakey.pem'
    Enter PEM pass phrase: pass
    Verifying - Enter PEM pass phrase: pass
    -----
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [AU]:UK
    State or Province Name (full name) [Some-State]:Chernihiv
    Locality Name (eg, city) []:Chernihiv
    Organization Name (eg, company) [Internet Widgits Pty Ltd]:University
    Organizational Unit Name (eg, section) []:student
    Common Name (eg, YOUR name) []:localhost
    Email Address []:proger@localhost
    
    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []:
    An optional company name []:
    Using configuration from /etc/ssl/openssl.cnf
    Enter pass phrase for ./demoCA/private/./cakey.pem:
    Check that the request matches the signature
    Signature ok
    Certificate Details:
            Serial Number:
                c6:55:7e:58:1b:4d:9c:7e
            Validity
                Not Before: Nov 25 13:17:31 2010 GMT
                Not After : Nov 24 13:17:31 2013 GMT
            Subject:
                countryName               = UK
                stateOrProvinceName       = Chernihiv
                organizationName          = University
                organizationalUnitName    = student
                commonName                = localhost
                emailAddress              = proger@localhost
            X509v3 extensions:
                X509v3 Subject Key Identifier: 
                    C7:98:1E:68:A7:3A:C4:B2:46:C8:88:99:C8:D5:CA:66:D3:94:23:66
                X509v3 Authority Key Identifier: 
                    keyid:C7:98:1E:68:A7:3A:C4:B2:46:C8:88:99:C8:D5:CA:66:D3:94:23:66
    
                X509v3 Basic Constraints: 
                    CA:TRUE
    Certificate is to be certified until Nov 24 13:17:31 2013 GMT (1095 days)
    
    Write out database with 1 new entries
    Data Base Updated
    progerlaptop:/usr/share/ssl/misc # ./CA.sh -newreq
    Generating a 1024 bit RSA private key
    ............++++++
    .........................++++++
    writing new private key to 'newkey.pem'
    Enter PEM pass phrase: pass
    Verifying - Enter PEM pass phrase: pass
    -----
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [AU]:UK
    State or Province Name (full name) [Some-State]:Chernihiv
    Locality Name (eg, city) []:Chernihiv
    Organization Name (eg, company) [Internet Widgits Pty Ltd]:University
    Organizational Unit Name (eg, section) []:student
    Common Name (eg, YOUR name) []:localhost
    Email Address []:proger@localhost
    
    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []:
    An optional company name []:
    Request is in newreq.pem, private key is in newkey.pem
    
    progerlaptop:/usr/share/ssl/misc # CA.sh -sign
    Using configuration from /etc/ssl/openssl.cnf
    Enter pass phrase for ./demoCA/private/cakey.pem: pass
    ...
    Sign the certificate? [y/n]:y
    ...
    Signed certificate is in newcert.pem
    

    已将密钥和证书复制到我的Tomcat目录。

    cp newcert.pem newkey.pem /path/to/tomcat-6.0.29/ssl/
    

    已将连接器添加到my server.xml:

       <Connector port="8443" maxHttpHeaderSize="8192" 
          maxThreads="150" minSpareThreads="25" maxSpareThreads="75" 
          enableLookups="false" disableUploadTimeout="true" 
          acceptCount="100" scheme="https" secure="true" 
          SSLEngine="on". 
          SSLCertificateFile="${catalina.base}/ssl/newcert.pem" 
          SSLCertificateKeyFile="${catalina.base}/ssl/newkey.pem". 
          SSLPassword="pass"/>
    

    然后我开始catalina.sh跑。 当我去 https://localhost:8443/ 我看到了这个严重的错误。 我什么时候做错了?
    提前谢谢你

    5 回复  |  直到 8 年前
        1
  •  4
  •   Community CDub    8 年前

    Tomcat 6及以上?如已回答的,您需要将sslenabled设置为“真”。 here here .

        2
  •  0
  •   Thiago Figueiro John Mee    14 年前

    看起来您正在使用apr/openssl进行https,在这种情况下sslengine=“on”是正确的。

    是否安装了libtcnative?

    假设Tomcat 6: http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html

    快速步骤:

    tar zxf tomcat-native-1.1.20-src.tar.gz
    cd tomcat-native-1.1.20-src/jni/native/
    ./configure --with-apr=/usr/bin/apr-1-config --with-ssl=yes
    make && make install
    cd /usr/java/default/jre/lib/amd64/
    ln -s /usr/local/apr/lib/libtcnative-1.so
    

    当你启动Tomcat时,你必须在catalina.out中看到这一行:

    INFO: Loaded APR based Apache Tomcat Native library 1.1.20.
    

    另一种方法是使用JSSE,并将证书/密钥添加到Java密钥存储库(.KiStand文件)。我发现Java密钥存储在使用中是一种痛苦,所以我通常会在APR中使用。

        3
  •  0
  •   damian    13 年前

    我也有同样的问题。我通过添加 protocol="org.apache.coyote.http11.Http11NioProtocol" 到连接器

        4
  •  0
  •   Chen Levy    12 年前

    我希望你的机器里有密钥存储文件

    确保在server.xml文件中,并引用 link 这对你解决

         <Connector port=”8443” maxHttpHeaderSize=”8192″
          maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
          enableLookups=”false” disableUploadTimeout=”true”
          acceptCount=”100″ scheme=”https” secure=”true”
          **keystoreFile=”/../../../Tomcat/mycert.jks”**
          clientAuth=”false” sslProtocol=”TLS>
    
        5
  •  0
  •   akelec    8 年前

    我通过改变 港口 值。值443是保留的,所以我放入1443,重新启动Tomcat,它工作了。

    我的 Connector 是:

    <Connector port="1443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" keystoreFile="D:/path_to_ca.jks" 
        keystorePass="somePass" />
    

    现在URL是:

    https://localhost:1443/index.jsp

    干杯!