Skip to content

BorringSSL Handshake Failure  #420

@WiseNN

Description

@WiseNN

I am consistently getting an SSL Handshake Failure, and am having issues troubleshooting this. Any help would be much appreciated.

 handshakeFailed(NIOSSL.BoringSSLError.sslError([Error: 268436496 error:10000410:SSL routines:OPENSSL_internal:SSLV3_ALERT_HANDSHAKE_FAILURE at /Users/norriswise/Library/Developer/Xcode/DerivedData/ios-dc-bocetydygnmhxsdxqxaivnvasghk/SourcePackages/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/ssl/tls_record.cc:592])) file:[<unknown>] line:[0]]

tls_record.cc

 if (alert_level == SSL3_AL_FATAL) {
    OPENSSL_PUT_ERROR(SSL, SSL_AD_REASON_OFFSET + alert_descr);
    ERR_add_error_dataf("SSL alert number %d", alert_descr);
    *out_alert = 0;  // No alert to send back to the peer.
    return ssl_open_record_error;
  }

Swift Code:

 var tlsConfig = TLSConfiguration.makeClientConfiguration()
        tlsConfig.maximumTLSVersion = .tlsv12
        tlsConfig.minimumTLSVersion = .tlsv11
        tlsConfig.cipherSuiteValues = NIOTLSCipher.allCases
        tlsConfig.certificateVerification = .noHostnameVerification
        tlsConfig.certificateChain = [.certificate(nioCert!)]
        let privateKeyNIO = try? NIOSSLPrivateKey.init(bytes: privateKeyByteAry, format: .der)
        tlsConfig.privateKey = NIOSSLPrivateKeySource.privateKey(privateKeyNIO!)
        
        let clientConfig = GRPCTLSConfiguration.makeClientConfigurationBackedByNIOSSL(configuration: tlsConfig, hostnameOverride: config.sniName)
        
        var gRPCLogger = Logger.init(label: "[[GRPC-LOGG]]", factory: StreamLogHandler.standardOutput(label:))
        gRPCLogger.logLevel = .debug
        
        if config.enableTLS {
            clientConnection = ClientConnection.usingTLS(with: clientConfig, on: eventLoopGroup)
                .withTLSCustomVerificationCallback({ certAry, verificationEventLoop in

                                      verificationEventLoop.succeed(.certificateVerified) //forcing success for testing purposes

                                  }                    
                             })
                .withBackgroundActivityLogger(gRPCLogger)
                .withErrorDelegate(self)
            clientConnection.withConnectionBackoff(retries: .upTo(3))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions