ความปลอดภัยสําหรับ CoAP
โมดูลนี้ประกอบด้วยฟังก์ชันที่ควบคุมการสื่อสารของ CoAP Secure (CoAP over DTLS)
สรุป
ฟังก์ชันในโมดูลนี้พร้อมใช้งานเมื่อเปิดใช้ฟีเจอร์ API ความปลอดภัย CoAP (OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
)
ประเภทคําสั่ง |
|
---|---|
otHandleCoapSecureClientConnect)(bool aConnected, void *aContext)
|
Typedefvoid(*
ระบบจะเรียกตัวชี้เมื่อสถานะการเชื่อมต่อ DTLS เปลี่ยนไป |
ฟังก์ชัน |
|
---|---|
otCoapSecureAddBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource)
|
void
เพิ่มทรัพยากรที่บล็อกด้วยเซิร์ฟเวอร์ CoAP Secure
|
otCoapSecureAddResource(otInstance *aInstance, otCoapResource *aResource)
|
void
เพิ่มทรัพยากรไปยังเซิร์ฟเวอร์ CoAP Secure
|
otCoapSecureConnect(otInstance *aInstance, const otSockAddr *aSockAddr, otHandleCoapSecureClientConnect aHandler, void *aContext)
|
เริ่มต้นเซสชัน DTLS กับเพียร์
|
otCoapSecureDisconnect(otInstance *aInstance)
|
void
หยุดการเชื่อมต่อ DTLS
|
otCoapSecureGetPeerCertificateBase64(otInstance *aInstance, unsigned char *aPeerCert, size_t *aCertLength, size_t aCertBufferSize)
|
แสดงผลใบรับรอง peer x509 base64 ที่เข้ารหัส
|
otCoapSecureIsConnected(otInstance *aInstance)
|
bool
ระบุว่ามีการเชื่อมต่อเซสชัน DTLS หรือไม่
|
otCoapSecureIsConnectionActive(otInstance *aInstance)
|
bool
ระบุว่าเซสชัน DTLS ทํางานอยู่หรือไม่
|
otCoapSecureRemoveBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource)
|
void
นําทรัพยากรแบบบล็อกบล็อกออกจากเซิร์ฟเวอร์ CoAP Secure
|
otCoapSecureRemoveResource(otInstance *aInstance, otCoapResource *aResource)
|
void
นําทรัพยากรออกจากเซิร์ฟเวอร์ CoAP Secure
|
otCoapSecureSendRequest(otInstance *aInstance, otMessage *aMessage, otCoapResponseHandler aHandler, void *aContext)
|
ส่งคําขอ CoAP ผ่านการเชื่อมต่อ DTLS ที่ปลอดภัย
|
otCoapSecureSendRequestBlockWise(otInstance *aInstance, otMessage *aMessage, otCoapResponseHandler aHandler, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook)
|
ส่งคําขอ CoAP แบบบล็อกผ่านการเชื่อมต่อ DTLS ที่ปลอดภัย
|
otCoapSecureSendResponse(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
ส่งการตอบสนอง CoAP จากเซิร์ฟเวอร์ CoAP Secure
|
otCoapSecureSendResponseBlockWise(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook)
|
ส่งการตอบกลับ CoAP แบบบล็อกจากเซิร์ฟเวอร์ CoAP Secure
|
otCoapSecureSetCaCertificateChain(otInstance *aInstance, const uint8_t *aX509CaCertificateChain, uint32_t aX509CaCertChainLength)
|
void
ตั้งค่า CA ระดับบนสุดที่เชื่อถือ
|
otCoapSecureSetCertificate(otInstance *aInstance, const uint8_t *aX509Cert, uint32_t aX509Length, const uint8_t *aPrivateKey, uint32_t aPrivateKeyLength)
|
void
ตั้งค่าใบรับรอง X509 ของอุปกรณ์ในเครื่องด้วยคีย์ส่วนตัวที่สอดคล้องกันสําหรับเซสชัน DTLS ที่มี DTLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
|
otCoapSecureSetClientConnectedCallback(otInstance *aInstance, otHandleCoapSecureClientConnect aHandler, void *aContext)
|
void
ตั้งค่าการเรียกกลับที่เชื่อมต่อเมื่อไคลเอ็นต์เชื่อมต่อกับเซิร์ฟเวอร์ CoAP Secure
|
otCoapSecureSetDefaultHandler(otInstance *aInstance, otCoapRequestHandler aHandler, void *aContext)
|
void
ตั้งค่าเครื่องจัดการเริ่มต้นสําหรับคําขอ CoAP Secure ที่ไม่มีการจัดการ
|
otCoapSecureSetPsk(otInstance *aInstance, const uint8_t *aPsk, uint16_t aPskLength, const uint8_t *aPskIdentity, uint16_t aPskIdLength)
|
void
ตั้งค่าคีย์ที่แชร์ล่วงหน้า (PSK) และชุดการเข้ารหัส DTLS_PSK_WITH_AES_128_CCM_8
|
otCoapSecureSetSslAuthMode(otInstance *aInstance, bool aVerifyPeerCertificate)
|
void
ตั้งค่าโหมดการตรวจสอบสิทธิ์สําหรับการเชื่อมต่อแบบ Coap Secure
|
otCoapSecureStart(otInstance *aInstance, uint16_t aPort)
|
เริ่มต้นบริการ CoAP Secure
|
otCoapSecureStop(otInstance *aInstance)
|
void
หยุดเซิร์ฟเวอร์ CoAP Secure
|
ประเภทคําสั่ง
otHandleCoapSecureClientConnect
void(* otHandleCoapSecureClientConnect)(bool aConnected, void *aContext)
ระบบจะเรียกตัวชี้เมื่อสถานะการเชื่อมต่อ DTLS เปลี่ยนไป
รายละเอียด | |||||
---|---|---|---|---|---|
พารามิเตอร์ |
|
ฟังก์ชัน
otCoapSecureAddBlockWiseResource
void otCoapSecureAddBlockWiseResource(
otInstance *aInstance,
otCoapBlockwiseResource *aResource
)
เพิ่มทรัพยากรที่บล็อกด้วยเซิร์ฟเวอร์ CoAP Secure
รายละเอียด | |||||
---|---|---|---|---|---|
พารามิเตอร์ |
|
otCoapSecureAddResource
void otCoapSecureAddResource(
otInstance *aInstance,
otCoapResource *aResource
)
เพิ่มทรัพยากรไปยังเซิร์ฟเวอร์ CoAP Secure
รายละเอียด | |||||
---|---|---|---|---|---|
พารามิเตอร์ |
|
OTCoapSecureConnect
otError otCoapSecureConnect(
otInstance *aInstance,
const otSockAddr *aSockAddr,
otHandleCoapSecureClientConnect aHandler,
void *aContext
)
เริ่มต้นเซสชัน DTLS กับเพียร์
รายละเอียด | |||||||||
---|---|---|---|---|---|---|---|---|---|
พารามิเตอร์ |
|
||||||||
แสดงผลค่า |
|
OTCoapSecure ยกเลิกการเชื่อมต่อ
void otCoapSecureDisconnect(
otInstance *aInstance
)
หยุดการเชื่อมต่อ DTLS
รายละเอียด | |||
---|---|---|---|
พารามิเตอร์ |
|
otCoapSecureGetPeerCertificateBase64
otError otCoapSecureGetPeerCertificateBase64(
otInstance *aInstance,
unsigned char *aPeerCert,
size_t *aCertLength,
size_t aCertBufferSize
)
แสดงผลใบรับรอง peer x509 base64 ที่เข้ารหัส
รายละเอียด | |||||||||
---|---|---|---|---|---|---|---|---|---|
พารามิเตอร์ |
|
||||||||
แสดงผลค่า |
|
otCoapSecureIsConnected
bool otCoapSecureIsConnected(
otInstance *aInstance
)
ระบุว่ามีการเชื่อมต่อเซสชัน DTLS หรือไม่
รายละเอียด | |||||
---|---|---|---|---|---|
พารามิเตอร์ |
|
||||
แสดงผลค่า |
|
OTCoapSecureIsConnectionActive
bool otCoapSecureIsConnectionActive(
otInstance *aInstance
)
ระบุว่าเซสชัน DTLS ทํางานอยู่หรือไม่
รายละเอียด | |||||
---|---|---|---|---|---|
พารามิเตอร์ |
|
||||
แสดงผลค่า |
|
otCoapSecureRemoveBlockWiseResource
void otCoapSecureRemoveBlockWiseResource(
otInstance *aInstance,
otCoapBlockwiseResource *aResource
)
นําทรัพยากรแบบบล็อกบล็อกออกจากเซิร์ฟเวอร์ CoAP Secure
รายละเอียด | |||||
---|---|---|---|---|---|
พารามิเตอร์ |
|
OTCoapSecureRemoveResource
void otCoapSecureRemoveResource(
otInstance *aInstance,
otCoapResource *aResource
)
นําทรัพยากรออกจากเซิร์ฟเวอร์ CoAP Secure
รายละเอียด | |||||
---|---|---|---|---|---|
พารามิเตอร์ |
|
OTCoapSecureSendRequest
otError otCoapSecureSendRequest(
otInstance *aInstance,
otMessage *aMessage,
otCoapResponseHandler aHandler,
void *aContext
)
ส่งคําขอ CoAP ผ่านการเชื่อมต่อ DTLS ที่ปลอดภัย
ถ้าระบบต้องการการตอบสนองคําขอ คุณควรระบุข้อมูลฟังก์ชันและบริบทที่เกี่ยวข้อง ถ้าไม่ต้องการการตอบสนอง อาร์กิวเมนต์เหล่านี้ควรเป็นตัวชี้เป็นค่า NULL หากไม่ได้กําหนดรหัสข้อความไว้ในส่วนหัว (เท่ากับ 0) ฟังก์ชันนี้จะกําหนดรหัสข้อความที่ไม่ซ้ํากันให้กับข้อความ
รายละเอียด | |||||||||
---|---|---|---|---|---|---|---|---|---|
พารามิเตอร์ |
|
||||||||
แสดงผลค่า |
|
OTCoapSecureSendRequestBlockWise
otError otCoapSecureSendRequestBlockWise(
otInstance *aInstance,
otMessage *aMessage,
otCoapResponseHandler aHandler,
void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook,
otCoapBlockwiseReceiveHook aReceiveHook
)
ส่งคําขอ CoAP แบบบล็อกผ่านการเชื่อมต่อ DTLS ที่ปลอดภัย
สามารถใช้งานได้เมื่อเปิดใช้งานการกําหนดค่า OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE
ถ้าระบบต้องการการตอบสนองคําขอ คุณควรระบุข้อมูลฟังก์ชันและบริบทที่เกี่ยวข้อง ถ้าไม่ต้องการการตอบสนอง อาร์กิวเมนต์เหล่านี้ควรเป็นตัวชี้เป็นค่า NULL หากไม่ได้กําหนดรหัสข้อความไว้ในส่วนหัว (เท่ากับ 0) ฟังก์ชันนี้จะกําหนดรหัสข้อความที่ไม่ซ้ํากันให้กับข้อความ
รายละเอียด | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
พารามิเตอร์ |
|
||||||||||||
แสดงผลค่า |
|
คําตอบของ OTCoapSecureSend
otError otCoapSecureSendResponse(
otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo
)
ส่งการตอบสนอง CoAP จากเซิร์ฟเวอร์ CoAP Secure
รายละเอียด | |||||||
---|---|---|---|---|---|---|---|
พารามิเตอร์ |
|
||||||
แสดงผลค่า |
|
OTCoapSecureSendResponseBlockWise
otError otCoapSecureSendResponseBlockWise(
otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook
)
ส่งการตอบกลับ CoAP แบบบล็อกจากเซิร์ฟเวอร์ CoAP Secure
สามารถใช้งานได้เมื่อเปิดใช้งานการกําหนดค่า OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE
รายละเอียด | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
พารามิเตอร์ |
|
||||||||||
แสดงผลค่า |
|
OTCoapSecureSetCaCertificateChain
void otCoapSecureSetCaCertificateChain(
otInstance *aInstance,
const uint8_t *aX509CaCertificateChain,
uint32_t aX509CaCertChainLength
)
ตั้งค่า CA ระดับบนสุดที่เชื่อถือ
ซึ่งจําเป็นสําหรับการตรวจสอบความถูกต้องของใบรับรองการเพียร์
โหมด DTLS "ECDHE ECDSA ที่มี AES 128 CCM 8" สําหรับ CoAPS ของแอปพลิเคชัน
รายละเอียด | |||||||
---|---|---|---|---|---|---|---|
พารามิเตอร์ |
|
OTCoapSecureSetCertificate
void otCoapSecureSetCertificate(
otInstance *aInstance,
const uint8_t *aX509Cert,
uint32_t aX509Length,
const uint8_t *aPrivateKey,
uint32_t aPrivateKeyLength
)
ตั้งค่าใบรับรอง X509 ของอุปกรณ์ในเครื่องด้วยคีย์ส่วนตัวที่สอดคล้องกันสําหรับเซสชัน DTLS ที่มี DTLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
รายละเอียด | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
พารามิเตอร์ |
|
otCoapSecureSetClientConnectedCallback
void otCoapSecureSetClientConnectedCallback(
otInstance *aInstance,
otHandleCoapSecureClientConnect aHandler,
void *aContext
)
ตั้งค่าการเรียกกลับที่เชื่อมต่อเมื่อไคลเอ็นต์เชื่อมต่อกับเซิร์ฟเวอร์ CoAP Secure
รายละเอียด | |||||||
---|---|---|---|---|---|---|---|
พารามิเตอร์ |
|
otCoapSecureSetDefaultHandler
void otCoapSecureSetDefaultHandler(
otInstance *aInstance,
otCoapRequestHandler aHandler,
void *aContext
)
ตั้งค่าเครื่องจัดการเริ่มต้นสําหรับคําขอ CoAP Secure ที่ไม่มีการจัดการ
รายละเอียด | |||||||
---|---|---|---|---|---|---|---|
พารามิเตอร์ |
|
otCoapSecureSetPsk
void otCoapSecureSetPsk(
otInstance *aInstance,
const uint8_t *aPsk,
uint16_t aPskLength,
const uint8_t *aPskIdentity,
uint16_t aPskIdLength
)
ตั้งค่าคีย์ที่แชร์ล่วงหน้า (PSK) และชุดการเข้ารหัส DTLS_PSK_WITH_AES_128_CCM_8
รายละเอียด | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
พารามิเตอร์ |
|
OTCoapSecureSetSslAuthMode
void otCoapSecureSetSslAuthMode(
otInstance *aInstance,
bool aVerifyPeerCertificate
)
ตั้งค่าโหมดการตรวจสอบสิทธิ์สําหรับการเชื่อมต่อแบบ Coap Secure
ปิดใช้หรือเปิดใช้การยืนยันของใบรับรองแอปเทียบเท่า ต้องเรียกก่อนเริ่ม
รายละเอียด | |||||
---|---|---|---|---|---|
พารามิเตอร์ |
|
เริ่มCoapSecureStart
otError otCoapSecureStart(
otInstance *aInstance,
uint16_t aPort
)
เริ่มต้นบริการ CoAP Secure
รายละเอียด | |||||
---|---|---|---|---|---|
พารามิเตอร์ |
|
||||
แสดงผลค่า |
|
หยุดการใช้งาน CoapSecureStop
void otCoapSecureStop(
otInstance *aInstance
)
หยุดเซิร์ฟเวอร์ CoAP Secure
รายละเอียด | |||
---|---|---|---|
พารามิเตอร์ |
|
มาโคร
พอร์ต OT_DEFAULT_COAP_SECURE_PORT
OT_DEFAULT_COAP_SECURE_PORT 5684
พอร์ตที่ปลอดภัยของ CoAP เริ่มต้น ตามที่ระบุไว้ใน RFC 7252
แหล่งข้อมูล
หัวข้ออ้างอิง OpenThread API มาจากซอร์สโค้ด ซึ่งพร้อมใช้งานใน GitHub ดูข้อมูลเพิ่มเติมหรือมีส่วนร่วมในเอกสารประกอบได้ที่แหล่งข้อมูล