SSL Services

SSL Services

SSL service “ssl:C” #

Command HeaderAvailable since system-versionAvailable from service-sessionsDescription
0x000100021.0.0-0Basically main-onlyInitialize
0x000200C21.0.0-0CreateContext
0x000300001.0.0-0CreateRootCertChain
0x000400401.0.0-0DestroyRootCertChain
0x000500821.0.0-0Main-onlyAddTrustedRootCA
0x000600801.0.0-0Main-onlyRootCertChainAddDefaultCert
0x000700801.0.0-0Main-onlyRootCertChainRemoveCert
0x000800001.0.0-0CreateCrlStore. This writes an output u32 to cmdreply[2](created context handle).
0x000900401.0.0-0DestroyCrlStore(u32 contexthandle)
0x000A00821.0.0-0Main-onlyAddCrlToCrlStore(u32 contexthandle, u32 size, ((Size<<4) | 10), inbufptr)
0x000B00801.0.0-0Main-onlyAddInternalCrlToCrlStore(u32 contexthandle, u8 inval2)
0x000C00801.0.0-0Main-onlyRemoveCrlFromCrlStore(u32 contexthandle, u32 certcontexthandle) This removes the specified cert from the context.
0x000D00841.0.0-0Main-onlyOpenClientCertContext
0x000E00401.0.0-0Main-onlyOpenDefaultClientCertContext
0x000F00401.0.0-0Main-onlyCloseClientCertContext
0x001000001.0.0-0AllSeedRNG
0x001100421.0.0-0AllGenerateRandomData
0x001200421.0.0-0InitializeConnectionSession
0x001300401.0.0-0Context-onlyStartConnection
0x001400401.0.0-0Context-onlyStartConnectionGetOut
0x001500821.0.0-0Context-onlyRead
0x001600821.0.0-0Context-onlyReadPeek
0x001700821.0.0-0Write
0x001800801.0.0-0ContextSetRootCertChain
0x001900801.0.0-0Context-onlyContextSetClientCert
0x001A00801.0.0-0Context-onlySetCrlStore(u32 contexthandle, u32 handle) This writes a context handle created by command 0x00080000 into the session context.
0x001B00801.0.0-0Context-onlyContextClearOpt
0x001C00C41.0.0-0Context-onlyContextGetProtocolCipher
0x001D00401.0.0-0Context-onlyGetCertVerificationErrors(u32 contexthandle) Writes an output u32 from the context state to cmdreply[2].
0x001E00401.0.0-0AllDestroyContext
0x001F00821.0.0-0Context-onlyContextInitSharedmem
0x002000821.0.0-0Context-onlyAddEVPolicyID( contexthandle, u32 size, ((Size<<4) | 10), inbufptr) The input buffer is handled as a string.

Going by strings in the SSL sysmodule it appears the sysmodule uses RSA BSAFE(like certain other 3DS software), this is also likely where the “ssl:C” name comes from(RSA BSAFE “SSL-C”).

Similar to HTTPC, each SSL context is used with a dedicated service session which gets opened after creating that context. Following creating the context + opening the service session, SSLC:InitializeConnectionSession is used from that service session for that context. Afterwards, all commands which require a handle for this context are done with this dedicated service session.

Internally there’s a separate object vtable used with the above SSLC commands, for the main session(where SSLC:InitializeConnectionSession wasn’t used), and context sessions where SSLC:InitializeConnectionSession was used. Error 0xD960BBF4 will be returned if a command was used with the wrong session type.

Like some other commands, 0x001F0082 and 0x00200082 are not used by HTTP-sysmodule.

Among commands 0x00180080..0x001B0080 none of them are completely mandatory. However, with the default settings at bare minimum a RootCertChain needs selected otherwise an untrusted-RootCA error will trigger eventually.

It’s unknown whether TLS server->client connections are supported.

The highest supported TLS protocol version is v1.1(this is the version used by default).

Commands 0x00080000..0x000C0080 #

These appear to be basically the same as the RootCertChain 0x00030000..0x00070080 commands, except with a different context. The equivalent of RootCertChainAddDefaultCert in this set(0x000B0080) is not usable however.

It’s unknown what this context is actually used for. Trying to use this seems to have no affect on the TLS connection at all, it seems like the cert isn’t even parsed.

Cert verification #

The server TLS cert not-before/not-after timestamps are not validated using the system-date which can be set via System Settings(it’s possible these timestamps are not validated at all).

SSLOpt #

Flag (BIT)Description
0x000 (??)Don’t verify certificate at all
0x001 (00)Verify Common Name (CN)
0x002 (01)Verify RootCA
0x004 (02)Verify date
0x008 (03)Verify cert chain
0x010 (04)Verify “subject alt name” (required for multi-address certificates)
0x020 (05)Verify cert EV
0x200 (09)Makes certification validation always succeed
0x800 (11)Disable use of TLSv1.1 (hence fallback to TLSv1.0)

This is the options field initialized during SSLC:CreateContext, and cleared via SSLC:ContextClearOpt. When the context is initially created, the options field initially has bitmask 0x1B set(besides the additional bits specified via SSLC:CreateContext).

Error codes #

Error codeDescription
0xD8A0B801Generic error, it means “this is not an SSL connection”
0xD840B802EWOULDBLOCK while trying to read
0xD840B803EWOULDBLOCK while trying to write
0xD840B807EWOULDBLOCK while calling sslcStartConnection()
0xD8A0B805Syscall error, usually means there’s no more data to be read because connection is closed
0xD8A0B806End-of-stream reached, there is no more data to be read
0xD8A0B814Server cert verification failed since the RootCA isn’t trusted.
0xD8A0B836The specified RootCertChain handle was not found in the linked-list.

Category:Services