]> Chaos Git - corbenik/ctrulib.git/commitdiff
Added httpc AddTrustedRootCA.
authoryellows8 <yellows8@users.noreply.github.com>
Tue, 8 Mar 2016 23:19:51 +0000 (18:19 -0500)
committeryellows8 <yellows8@users.noreply.github.com>
Tue, 8 Mar 2016 23:19:51 +0000 (18:19 -0500)
libctru/include/3ds/services/httpc.h
libctru/source/services/httpc.c

index a0009fdf140292c6faa754cdc54dddbc8a8cb3fd..b1696160ff9000f9abbfe059ffb418b0f768847e 100644 (file)
@@ -121,6 +121,14 @@ Result httpcGetResponseStatusCode(httpcContext *context, u32* out, u64 delay);
  */
 Result httpcGetResponseHeader(httpcContext *context, char* name, char* value, u32 valuebuf_maxsize);
 
+/**
+ * @brief Adds a trusted RootCA cert to a HTTP context.
+ * @param context Context to use.
+ * @param cert Pointer to DER cert.
+ * @param certsize Size of the DER cert.
+ */
+Result httpcAddTrustedRootCA(httpcContext *context, u8 *cert, u32 certsize);
+
 /**
  * @brief Downloads data from the HTTP context into a buffer.
  * The *entire* content must be downloaded before using httpcCloseContext(), otherwise httpcCloseContext() will hang.
@@ -252,3 +260,12 @@ Result HTTPC_GetResponseHeader(Handle handle, Handle contextHandle, char* name,
  */
 Result HTTPC_GetResponseStatusCode(Handle handle, Handle contextHandle, u32* out);
 
+/**
+ * @brief Adds a trusted RootCA cert to a HTTP context.
+ * @param handle HTTPC service handle to use.
+ * @param contextHandle HTTP context handle to use.
+ * @param cert Pointer to DER cert.
+ * @param certsize Size of the DER cert.
+ */
+Result HTTPC_AddTrustedRootCA(Handle handle, Handle contextHandle, u8 *cert, u32 certsize);
+
index 25e1ff14c5efd2394a6a164d4787b6e2c3d956f8..6b3f03e0edbb7d0c3d8cb37ad52b0a764383f2b2 100644 (file)
@@ -164,6 +164,11 @@ Result httpcGetResponseStatusCode(httpcContext *context, u32* out, u64 delay)
        return HTTPC_GetResponseStatusCode(context->servhandle, context->httphandle, out);
 }
 
+Result httpcAddTrustedRootCA(httpcContext *context, u8 *cert, u32 certsize)
+{
+       return HTTPC_AddTrustedRootCA(context->servhandle, context->httphandle, cert, certsize);
+}
+
 Result httpcDownloadData(httpcContext *context, u8* buffer, u32 size, u32 *downloadedsize)
 {
        Result ret=0;
@@ -439,3 +444,19 @@ Result HTTPC_GetResponseStatusCode(Handle handle, Handle contextHandle, u32* out
        return cmdbuf[1];
 }
 
+Result HTTPC_AddTrustedRootCA(Handle handle, Handle contextHandle, u8 *cert, u32 certsize)
+{
+       u32* cmdbuf=getThreadCommandBuffer();
+
+       cmdbuf[0]=IPC_MakeHeader(0x24,2,2); // 0x240082
+       cmdbuf[1]=contextHandle;
+       cmdbuf[2]=certsize;
+       cmdbuf[3]=IPC_Desc_Buffer(certsize, IPC_BUFFER_R);
+       cmdbuf[4]=(u32)cert;
+
+       Result ret=0;
+       if(R_FAILED(ret=svcSendSyncRequest(handle)))return ret;
+
+       return cmdbuf[1];
+}
+