範例:順暢地跨多個網站共用憑證

如何設定多個網站的憑證共用功能:

  • 指定主網域:選擇一個網域做為主要參考資料 指向連結。
  • 建立及代管 assetlinks.json 檔案
    • 主網域:在您的網域中建立及代管 assetlinks.json 檔案 主要網域列出所有共用憑證的網域。
    • 其他網域:在每個網域上建立並代管 assetlinks.json 檔案 每個網域則連回主要網域。

在以下範例中 example.com 做為主網域。所有其他 列出的網域共用憑證 example.com 等。

設定憑證共用功能前,請先確認您符合必要條件

如何宣告這些網站之間的憑證共用:

  1. 使用以下內容為主網域建立 assetlinks.json 檔案 內容:

      [
        {
          "relation": ["delegate_permission/common.get_login_creds"],
          "target": {
            "namespace": "web",
            "site": "https://example.com"
          }
        },
        {
          "relation": ["delegate_permission/common.get_login_creds"],
          "target": {
            "namespace": "web",
            "site": "https://example.org"
          }
        },
        {
          "relation": ["delegate_permission/common.get_login_creds"],
          "target": {
            "namespace": "web",
            "site": "https://example.net"
          }
        },
        {
          "relation": ["delegate_permission/common.get_login_creds"],
          "target": {
            "namespace": "web",
            "site": "https://myownpersonaldomain.com"
          }
        }
      ]
    
  2. 請在以下位置代管 Digital Asset Links JSON 檔案: 主要網址:https://example.com/.well-known/assetlinks.json

  3. 為參照的其他網域建立簡化版 assetlinks.json 檔案 主要網域的 assetlinks.json 檔案:

      [
        {
          "relation": ["delegate_permission/common.get_login_creds"],
          "target": {
            "namespace": "web",
            "site": "https://example.com"
          }
        }
      ]
    
  4. 這個 Digital Asset Links JSON 檔案的副本位於以下位置 在所有網域中:

    • example.org/.well-known/assetlinks.json
    • example.net/.well-known/assetlinks.json
    • mypersonaldomain.com/.well-known/assetlinks.json

完成上述步驟後,您已成功設定無縫憑證 跨多個網站共用內容所有列出的網站現在皆可共用憑證。

如此一來,您就能更輕鬆地將新網站加入到 以及憑證共用網路

在憑證共用網路中新增網站

若要將網站新增至憑證共用網路:

  1. 更新主網域 (這個) 代管的 assetlinks.json 檔案 case, https://example.com) 新增陳述式,例如: ,列於包含新網域網址的清單中:

      ...
      {
        "relation": ["delegate_permission/common.get_login_creds"],
        "target": {
          "namespace": "web",
          "site": https://NEW_DOMAIN
        }
      }
      ...
    

    其中 NEW_DOMAIN 是新的網域名稱。

  2. 在新網域上建立及代管 assetlinks.json 檔案,連結會連至 主網域 (在本例中為 https://example.com)、 包含下列內容:

      [
        {
          "relation": ["delegate_permission/common.get_login_creds"],
          "target": {
            "namespace": "web",
            "site": "https://example.com"
          }
        }
      ]
    

其餘 assetlinks.json 檔案則維持不變。這個方法包括推送程式碼 可重複使用,並降低更新期間發生錯誤的可能性。