Part Number: LAUNCHCC3220MODASF
Hi,
I'm trying to get a TCP socket to listen for incoming TLS connections. The client sends a ClientHello but gets zero bytes back in reply and the asynchronous SimpleLinkSockEventHandler() is called with a SL_SOCKET_ASYNC_EVENT event where the type is 0, SL_SSL_ACCEPT, and value -300.
The comment for SL_SSL_ACCEPT says 'accept failed due to ssl issue ( tcp pass)'.
What does the -300 signify? It may help me fix the problem.
Here's the run of code from sl_Socket() up to sl_Listen() in case it helps.
SlSockAddrIn_t const httpsaddr = { .sin_family = SL_AF_INET, .sin_port = ENDIAN_U16_NtoB(443), .sin_addr = {ENDIAN_U32_NtoB(0x00000000)}, .sin_zero = {0}, }; CALL(sl_Socket, (SL_AF_INET, SL_SOCK_STREAM, SL_SEC_SOCKET)); httpfd = ret; CALL(sl_Bind, (httpfd, (SlSockAddr_t *)&httpsaddr, sizeof httpsaddr)); /*lint !e740 */ SlSockSecureMethod_t meth = { .SecureMethod = SL_SO_SEC_METHOD_TLSV1_2, }; CALL(sl_SetSockOpt, (httpfd, SL_SOL_SOCKET, SL_SO_SECMETHOD, &meth, sizeof meth)); SlSockSecureMask_t ciph = { .SecureMask = SL_SEC_MASK_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 | SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 | SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 | SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 | SL_SEC_MASK_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 | SL_SEC_MASK_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256, }; CALL(sl_SetSockOpt, (httpfd, SL_SOL_SOCKET, SL_SO_SECURE_MASK, &ciph, sizeof ciph)); /* Diffie Hellman parameters file, required for DHE cipher suites. */ static char const dhparam[] = "prime256v1-param.der"; CALL(sl_SetSockOpt, (httpfd, SL_SOL_SOCKET, SL_SO_SECURE_FILES_PEER_CERT_OR_DH_KEY_FILE_NAME, dhparam, STRLEN(dhparam))); /* Private key, PEM or DER format. RSA key mandates RSA ciphers, * DH key likewise for DH ciphers. */ static char const privkey[] = "private-key.der"; CALL(sl_SetSockOpt, (httpfd, SL_SOL_SOCKET, SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME, privkey, STRLEN(privkey))); /* Setting root CA file, PEM or DER format, would check client * verification, raising asynchronous SL_ERROR_BSD_ESEC_NO_PEER_CERT * on failure. */ // static char const rootcert[] = "root-cert-auth.der"; // CALL(sl_SetSockOpt, (httpfd, SL_SOL_SOCKET, // SL_SO_SECURE_FILES_CA_FILE_NAME, rootcert, STRLEN(rootcert))); /* Server certificate or certificate chain in PEM or DER format, PEM * if chain. */ static char const certchain[] = "self-signed-cert.der"; CALL(sl_SetSockOpt, (httpfd, SL_SOL_SOCKET, SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME, certchain, STRLEN(certchain))); CALL(sl_Listen, (httpfd, 3));
The three *.der mentioned are all put into the external flash with
uniflash project add_file --name $project --file $PWD/$f --fs_path $f --overwrite
where $f is each of them in turn.
Thanks, Ralph.