---
title: 電子証明書でデバイス認証を強化せよ
tags: 
author: [MATSUOKA Takashi](https://www.docswell.com/user/matsujirushi)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/47ZV5L83E3.jpg?width=480
description: 2022/11/28 【オンライン】エッジAI入門＆活用シリーズ#4『Azure IoTサービス』編  https://algyan.connpass.com/event/265438/
published: November 28, 22
canonical: https://www.docswell.com/s/matsujirushi/KVVNG3-2024-01-18-083229
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/47ZV5L83E3.jpg)

電子証明書で
デバイス認証を
強化せよ
- 2022/11/28 【オンライン】エッジAI入門＆活用シリー
ズ#4『Azure IoTサービス』編 -
Takashi Matsuoka
@matsujirushi12


# Page. 2

![Page Image](https://bcdn.docswell.com/page/YJ659WPZ7V.jpg)

Takashi Matsuoka
@matsujirushi12
「e」3つ
2017～ MVP for Windows Development
2020～
for Microsoft Azure
2022～
for Internet of Things
1991年大手メーカーに入社し、工場の自動
化や情報システムの開発、運用に従事。
2017年8月、Seeed株式会社設立時に転職。
組み込みデバイスの開発環境整備やライブ
ラリ開発を担当。
↑
“初心者の次”へ行くのに身に付けるべきスキルをとりまとめた書籍


# Page. 3

![Page Image](https://bcdn.docswell.com/page/GJ5YNMK9J4.jpg)

本セッションで話すこと
• Azure IoT Hubとデバイスの認証
• Azure IoT Hub Device Provisioning Service、Azure IoT Centralは除外
• X.509証明書や公開鍵暗号、デジタル署名、PKI、TLSは解説しません
• 良質な書籍やWebで学んでください
言いたいことがあれば#ALGYANでツィートを！
（質問、要望、感想、意見、反論などなど）


# Page. 4

![Page Image](https://bcdn.docswell.com/page/LE352WZ2J5.jpg)

オススメの書籍
発売日：2018/10/2
ページ数：196
発売日：2018/6/4
ページ数：520
発売日：2017/8/3
ページ数：720
発売日：2003/5/31
ページ数：848


# Page. 5

![Page Image](https://bcdn.docswell.com/page/8EDDZKR6EG.jpg)

Azureサービスとデバイスの接続
Devices
Internet
IoT Device
Cloud Gateway
Azure Services
One-way
Azure
Event Hubs
Azure
Functions
Azure
Digital Twins
Azure
Data Explorer
Azure
IoT Hub
Azure
Stream Analytics
Azure
Logic Apps
Azure
App Service
Azure
IoT Edge
Two-way
IoT Device
Azure
IoT Edge


# Page. 6

![Page Image](https://bcdn.docswell.com/page/V7PXDKMZE8.jpg)

Azure IoT CentralはAzure IoT Hubでインプリ
引用：【オンライン】『Azure IoT Central』入門セミナー！エンジニア達が全体像を解説します。
https://youtu.be/hmoRw4WqtMc?t=1884


# Page. 7

![Page Image](https://bcdn.docswell.com/page/2JVL1V9M7Q.jpg)

Azure IoT Hubとデバイスの認証
１．Azure IoT Hubを認証
サーバ証明書とドメイン確認
IoT Device #1
２．デバイスを認証
2-A. SAS方式
2-B. X.509方式
Azure
IoT Hub
IoT Device #1
IoT Device #2
参考：デバイスの認証
https://learn.microsoft.com/ja-jp/azure/iot-hub/iot-hub-tls-support#device-authentication


# Page. 8

![Page Image](https://bcdn.docswell.com/page/5EGX2LZXJL.jpg)

1. Azure IoT Hubを認証
サーバ証明書とドメイン確認
IoT Device
サーバ証明書（+公開鍵）
*.azure-devices.net
Azure
IoT Hub
発行者
ルート証明書（+公開鍵）
Baltimore CyberTrust Root
中間証明書（+公開鍵）
MSFT BALT RS256 CA
サーバ秘密鍵
発行者
参考：IoT Hub でのトランスポート層セキュリティ (TLS) のサポート
https://learn.microsoft.com/ja-jp/azure/iot-hub/iot-hub-tls-support


# Page. 9

![Page Image](https://bcdn.docswell.com/page/4JQ8PYL57P.jpg)

2-A. デバイスを認証 – SAS方式
SAS確認
IoT Device
Azure
IoT Hub
SASトークン
SharedAccessSignature sr=myhub.azure-devices.net%2fdevices%2fdevice1&amp;
sig=13y8ejUk2z7PLmvtwR5RqlGBOVwiq7rQR3WZ5xZX3N4%3D&amp;se=1456971697
対称鍵
一致
生成
引用：IoT Hubへ接続するときの認証やキーなど
https://matsujirushi.hatenablog.jp/entry/2019/12/31/113519
対称鍵
参考：デバイスとして SAS トークンを使用する
https://learn.microsoft.com/ja-jp/azure/iot-hub/iot-hub-dev-guide-sas?
tabs=node#use-sas-tokens-as-a-device


# Page. 10

![Page Image](https://bcdn.docswell.com/page/K742YWDVJ1.jpg)

2-B. デバイスを認証 – X.509方式
デバイス証明書確認
IoT Device
デバイス
秘密鍵
デバイス証明書（+公開鍵）
device1
Azure
IoT Hub
X.509自己署名
一致
発行者
拇印
X.509CA署名
ルート証明書（+公開鍵）
参考：デバイスの認証
https://learn.microsoft.com/ja-jp/azure/iot-hub/iot-hub-tls-support#device-authentication


# Page. 11

![Page Image](https://bcdn.docswell.com/page/LJ1M6YZ4EG.jpg)

SAS方式、X.509方式
SAS方式
✓ 取り扱いがシンプル
対称鍵
✓ TLS以外でも使える
X.509方式
✓ 柔軟かつ堅牢な認証基盤
拇印、中間証明書、ルート証明書
有効期間、失効
暗号スイート
HSM
✓ 隠蔽は難しいかも？
HSMのHMAC-SHA256を使う？
✓ 選択と運用が必要
証明書の再発行
✓ コア部分の実装が辛い
✓ Azure IoT Edgeの透過ゲートウェイでは使えない？


# Page. 12

![Page Image](https://bcdn.docswell.com/page/GJW3WG9ZJ2.jpg)

本番環境はX.509方式を推奨
“Devices authenticate with the IoT Central application by using either a shared
access signature (SAS) token or an X.509 certificate. X.509 certificates are
recommended in production environments.”
引用：Device authentication concepts in IoT Central
https://learn.microsoft.com/en-us/azure/iot-central/core/concepts-device-authentication


# Page. 13

![Page Image](https://bcdn.docswell.com/page/4EZV5L9LJ3.jpg)

X.509方式 – 選択と運用
✓ ルート証明書更新
FOTA
✓ デバイス秘密鍵隠蔽
HSM
✓ デバイス公開鍵正当性確認
拇印、PKI
✓ デバイス証明書期間
✓ デバイス証明書発行
（自己署名）、私設CA署名、CAサービス署名
✓ デバイス証明書更新
FOTA


# Page. 14

![Page Image](https://bcdn.docswell.com/page/Y7659WKMEV.jpg)

Device Update for Azure IoT Hub
引用：Device Update for IoT Hub is now generally available
https://techcommunity.microsoft.com/t5/internet-of-things-blog/device-update-for-iot-hub-is-now-generally-available/ba-p/3664784


# Page. 15

![Page Image](https://bcdn.docswell.com/page/G75YNMPQ74.jpg)

まとめ
• 正しいAzure IoT Hubなのかは、サーバ証明書で確認
• 正しいデバイスなのかは、SASトークン or デバイス証明書で認証
• SAS方式 … SASトークン
• X.509方式 … デバイス証明書
• X.509方式はイロイロと考えなければいけないことが多い
• デバイス証明書発行
• デバイス証明書更新
• マイクロソフトは本番環境ではX.509方式を推奨
• 暗に、開発環境はSAS方式のが良いと言ってる？


# Page. 16

![Page Image](https://bcdn.docswell.com/page/9J2G596WJR.jpg)

Azure IoT TLS: Critical changes are almost here!
https://techcommunity.microsoft.com/t5/internet-of-things-blog/azure-iot-tls-critical-changes-are-almost-here-and-why-you/ba-p/2393169
参考：待ったなし！ いますぐAzure IoTのルート証明書を確認せよ！（2023年2月期限）
https://qiita.com/matsujirushi/items/6234b7ff79acb355f876


# Page. 17

![Page Image](https://bcdn.docswell.com/page/DEYVK499EM.jpg)

https://algyan.connpass.com/event/267859/


