• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# net_ssl_c.h
2
3## 概述
4
5定义SSL/TLS证书链校验模块C接口数据结构。
6
7**引用文件:** <network/netstack/net_ssl/net_ssl_c.h>
8
9**库:** libnet_ssl.so
10
11**系统能力:** SystemCapability.Communication.NetStack
12
13**起始版本:** 11
14
15**相关模块:** [netstack](capi-netstack.md)
16
17## 汇总
18
19### 函数
20
21| 名称 | 描述 |
22| -- | -- |
23| [uint32_t OH_NetStack_CertVerification(const struct NetStack_CertBlob *cert, const struct NetStack_CertBlob *caCert)](#oh_netstack_certverification) | 证书链校验接口。 |
24| [int32_t OH_NetStack_GetPinSetForHostName(const char *hostname, NetStack_CertificatePinning *pin)](#oh_netstack_getpinsetforhostname) | 获取证书锁定信息。 |
25| [int32_t OH_NetStack_GetCertificatesForHostName(const char *hostname, NetStack_Certificates *certs)](#oh_netstack_getcertificatesforhostname) | 获取证书信息。 |
26| [void OH_Netstack_DestroyCertificatesContent(NetStack_Certificates *certs)](#oh_netstack_destroycertificatescontent) | 释放证书内容。 |
27| [int32_t OH_Netstack_IsCleartextPermitted(bool *isCleartextPermitted)](#oh_netstack_iscleartextpermitted) | 整体明文HTTP是否允许。 |
28| [int32_t OH_Netstack_IsCleartextPermittedByHostName(const char *hostname, bool *isCleartextPermitted)](#oh_netstack_iscleartextpermittedbyhostname) | 按域名明文HTTP是否允许。 |
29
30
31## 函数说明
32
33### OH_NetStack_CertVerification()
34
35```
36uint32_t OH_NetStack_CertVerification(const struct NetStack_CertBlob *cert, const struct NetStack_CertBlob *caCert)
37```
38
39**描述**
40
41对外暴露的证书链校验接口。
42
43**系统能力:** SystemCapability.Communication.NetStack
44
45**起始版本:** 11
46
47
48**参数:**
49
50| 参数项 | 描述 |
51| -- | -- |
52| [const struct NetStack_CertBlob](capi-netstack-netstack-certblob.md) *cert | 用户传入的待校验证书。 |
53| [const struct NetStack_CertBlob](capi-netstack-netstack-certblob.md) *caCert |   用户指定的证书,若为空则以系统预置证书进行校验。 |
54
55**返回:**
56
57| 类型 | 说明 |
58| -- | -- |
59| uint32_t | 0 - 成功。<br> 2305001 - 未指定的错误。<br> 2305002 - 无法获取颁发者证书。<br> 2305003 - 无法获取证书吊销列表(CRL)。<br> 2305004 - 无法解密证书签名。<br> 2305005 - 无法解密CRL签名。<br> 2305006 - 无法解码颁发者公钥。<br> 2305007 - 证书签名失败。<br> 2305008 - CRL签名失败。<br> 2305009 - 证书尚未生效。<br> 2305010 - 证书已过期。<br> 2305011 - CRL尚未有效。<br> 2305012 - CRL已过期。<br> 2305023 - 证书已被吊销。<br> 2305024 - 证书颁发机构(CA)无效。<br> 2305027 - 证书不受信任。 |
60
61### OH_NetStack_GetPinSetForHostName()
62
63```
64int32_t OH_NetStack_GetPinSetForHostName(const char *hostname, NetStack_CertificatePinning *pin)
65```
66
67**描述**
68
69获取证书锁定信息。
70
71**系统能力:** SystemCapability.Communication.NetStack
72
73**起始版本:** 12
74
75
76**参数:**
77
78| 参数项 | 描述 |
79| -- | -- |
80| const char *hostname | 主机名。 |
81| [NetStack_CertificatePinning](capi-netstack-netstack-certificatepinning.md) *pin | 证书锁定信息的结构体。 |
82
83**返回:**
84
85| 类型 | 说明 |
86| -- | -- |
87| int32_t | 0 - 成功。<br>         401 - 参数设置错误。<br>         2305999 - 内存错误。 |
88
89### OH_NetStack_GetCertificatesForHostName()
90
91```
92int32_t OH_NetStack_GetCertificatesForHostName(const char *hostname, NetStack_Certificates *certs)
93```
94
95**描述**
96
97获取证书信息。
98
99**系统能力:** SystemCapability.Communication.NetStack
100
101**起始版本:** 12
102
103
104**参数:**
105
106| 参数项 | 描述 |
107| -- | -- |
108| const char *hostname | 主机名。 |
109| [NetStack_Certificates](capi-netstack-netstack-certificates.md) *certs | 证书信息的结构体。 |
110
111**返回:**
112
113| 类型 | 说明 |
114| -- | -- |
115| int32_t | 0 - 成功。<br>         401 - 参数设置错误。<br>         2305999 - 内存错误。 |
116
117### OH_Netstack_DestroyCertificatesContent()
118
119```
120void OH_Netstack_DestroyCertificatesContent(NetStack_Certificates *certs)
121```
122
123**描述**
124
125释放证书内容。
126
127**系统能力:** SystemCapability.Communication.NetStack
128
129**起始版本:** 12
130
131
132**参数:**
133
134| 参数项 | 描述 |
135| -- | -- |
136| [NetStack_Certificates](capi-netstack-netstack-certificates.md) *certs | 证书信息。 |
137
138### OH_Netstack_IsCleartextPermitted()
139
140```
141int32_t OH_Netstack_IsCleartextPermitted(bool *isCleartextPermitted)
142```
143
144**描述**
145
146整体明文HTTP是否允许。
147
148**需要权限:** ohos.permission.INTERNET
149
150**起始版本:** 18
151
152
153**参数:**
154
155| 参数项 | 描述 |
156| -- | -- |
157| bool *isCleartextPermitted | 输出参数,如果允许明文流量,则true,否则false。 |
158
159**返回:**
160
161| 类型 | 说明 |
162| -- | -- |
163| int32_t | 0 - 成功。<br>         201 - 权限被拒。<br>         401 - 参数错误。 |
164
165### OH_Netstack_IsCleartextPermittedByHostName()
166
167```
168int32_t OH_Netstack_IsCleartextPermittedByHostName(const char *hostname, bool *isCleartextPermitted)
169```
170
171**描述**
172
173按域名明文HTTP是否允许。
174
175**需要权限:** ohos.permission.INTERNET
176
177**起始版本:** 18
178
179
180**参数:**
181
182| 参数项 | 描述 |
183| -- | -- |
184| const char *hostname | 主机名。 |
185| bool *isCleartextPermitted | 输出参数,如果允许指定主机名的明文流量,则true,否则false。 |
186
187**返回:**
188
189| 类型 | 说明 |
190| -- | -- |
191| int32_t | 0 - 成功。<br>         201 - 权限被拒。<br>         401 - 参数错误。 |
192
193