MeWrite Docs

NET::ERR_CERT_DATE_INVALID

SSL証明書の有効期限に問題がある場合のエラー

概要

NET::ERR_CERT_DATE_INVALIDは、SSL/TLS証明書の有効期限が切れているか、まだ有効になっていない場合、またはシステムの時刻が正しくない場合に発生するエラーです。

エラーメッセージ

Your connection is not private
Attackers might be trying to steal your information from example.com
NET::ERR_CERT_DATE_INVALID
この接続ではプライバシーが保護されません
NET::ERR_CERT_DATE_INVALID
この証明書は有効期限が切れています。

原因

  1. 証明書の期限切れ: 証明書の有効期限が過ぎている
  2. 証明書がまだ有効でない: 開始日が未来の日付
  3. システム時刻のずれ: PCの日時設定が不正確
  4. BIOSバッテリー切れ: 時刻がリセットされている

解決策

1. システム時刻を確認・修正

Windows:

1. タスクバーの時計を右クリック
2. 「日付と時刻の調整」を選択
3. 「時刻を自動的に設定する」をオン
4. 「タイムゾーンを自動的に設定する」をオン
5. 「今すぐ同期」をクリック

コマンドラインで:
w32tm /resync

macOS:

1. システム環境設定 > 日付と時刻
2. 鍵をクリックして変更を許可
3. 「日付と時刻を自動的に設定」にチェック
4. サーバー: time.apple.com

コマンドラインで:
sudo sntp -sS time.apple.com

Linux:

1
2
3
4
5
6
7
8
# NTP で時刻同期
sudo timedatectl set-ntp true

# 手動で時刻設定
sudo timedatectl set-time "2026-01-27 12:00:00"

# NTPサーバーと同期
sudo ntpdate pool.ntp.org

2. 証明書の有効期限を確認

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# OpenSSL で確認
openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | \
  openssl x509 -noout -dates

# 出力例:
# notBefore=Jan  1 00:00:00 2025 GMT
# notAfter=Dec 31 23:59:59 2025 GMT

# 残り日数を確認
echo | openssl s_client -connect example.com:443 2>/dev/null | \
  openssl x509 -noout -enddate

# curl で詳細確認
curl -vI https://example.com 2>&1 | grep -E "(expire|start) date"

3. 証明書の更新(サーバー管理者向け)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Let's Encrypt 証明書の更新
sudo certbot renew

# 強制更新
sudo certbot renew --force-renewal

# 更新後のサービス再起動
sudo systemctl reload nginx
# または
sudo systemctl reload apache2

# 自動更新の設定確認
sudo certbot renew --dry-run

4. 証明書の自動更新設定

1
2
3
4
5
# cron で自動更新(Let's Encrypt)
sudo crontab -e

# 毎日午前3時に更新チェック
0 3 * * * certbot renew --quiet --post-hook "systemctl reload nginx"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# systemd timer で自動更新
# /etc/systemd/system/certbot-renewal.timer
[Unit]
Description=Certbot Renewal Timer

[Timer]
OnCalendar=*-*-* 03:00:00
RandomizedDelaySec=3600

[Install]
WantedBy=timers.target

5. 証明書の有効期限監視

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 期限切れ30日前に警告するスクリプト
#!/bin/bash
DOMAIN="example.com"
WARN_DAYS=30

expiry_date=$(echo | openssl s_client -connect $DOMAIN:443 2>/dev/null | \
  openssl x509 -noout -enddate | cut -d= -f2)
expiry_epoch=$(date -d "$expiry_date" +%s)
current_epoch=$(date +%s)
days_left=$(( ($expiry_epoch - $current_epoch) / 86400 ))

if [ $days_left -lt $WARN_DAYS ]; then
  echo "警告: $DOMAIN の証明書は $days_left 日後に期限切れです"
  # メール通知など
fi
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Node.js での証明書チェック
const https = require('https');

function checkCertExpiry(hostname) {
  return new Promise((resolve, reject) => {
    const options = {
      hostname,
      port: 443,
      method: 'GET',
      rejectUnauthorized: false
    };

    const req = https.request(options, (res) => {
      const cert = res.socket.getPeerCertificate();
      const expiry = new Date(cert.valid_to);
      const daysLeft = Math.floor((expiry - Date.now()) / (1000 * 60 * 60 * 24));

      resolve({
        hostname,
        expiry: cert.valid_to,
        daysLeft,
        issuer: cert.issuer.O
      });
    });

    req.on('error', reject);
    req.end();
  });
}

// 使用例
checkCertExpiry('example.com').then(console.log);

BIOSバッテリー問題の対処

症状:
- PC起動時に毎回日時がリセットされる
- 1970年や2000年に戻る

対処:
1. BIOSで日時を手動設定
2. CMOSバッテリー(CR2032等)を交換
3. ノートPCの場合は内蔵バッテリーを確認

一時的な回避策(推奨しない)

Chrome:
エラーページで "thisisunsafe" とタイプすると一時的にアクセス可能
※ セキュリティリスクがあるため、本番環境では使用しない

開発環境のみ:
chrome --ignore-certificate-errors

Browser の他のエラー

最終更新: 2026-01-27