2017-11-23 19 views
0

하늘색 알림 허브를 조사 중이며 메시지를 보내고받는 데 성공했지만 프로그램 방식으로 허브를 구성해야합니다.프로그래밍 방식으로 또는 CLI를 통해 하늘색 알림 허브에 APNS 인증서를 업로드 할 수 있습니까?

알림 허브를 만들 수있는 유일한 방법은 this one과 같은 azuredeploy.json ARM 템플릿이있는 azure cli를 사용하는 것입니다. 그러나 APNS 인증서를 추가하는 방법에 대한 정보를 찾을 수 없습니다.

Google 허브에서 생성 된 자동화 스크립트를 보면 google firebase API 키 또는 APNS 인증서가 없음을 알 수 있습니다. 이것이 가능합니까? 아니면 언제나 하늘빛 문을 통해 이루어져야합니다.

UPDATED : 약간의 문제가있는 arm 템플릿을 사용하여 알림 허브 네임 스페이스를 만들었지 만 만들려고 할 때 "잘못된 요청"(상관 ID - 3faee649-7084-436d-8d7e-4a9c6f79cc4e)이 나타납니다. apns 인증서가있는 알림 허브 자체

this post은 비슷한 문제가있는 사람이지만 apns의 키는 내 것보다 훨씬 짧습니다. 나는 문자 그대로 5000+ 문자가 틀린 인증서 파일에서 base64 문자열을 만들었지 만 그 값이 틀리다고 가정합니다.하지만 사과에서 어떤 값을 가져올 지 알 수 없습니다.

내 템플릿은 다음과 같습니다

apnsCredentials 속성에
{ 
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
    "contentVersion": "1.0.0.0", 
    "parameters": { 
    "Gcm.GoogleApiKey": { 
     "type": "string", 
     "metadata": { 
     "description": "Google Cloud Messaging API Key" 
     }, 
     "defaultValue": "" 
    }, 
    "Apns.apnsCertificate": { 
     "type": "string", 
     "metadata": { 
      "description": "A certificate (in base 64 format) provided by Apple on the iOS Provisioning Portal" 
     } 
     }, 
     "Apns.certificateKey": { 
     "type": "string", 
     "metadata": { 
      "description": "The Certificate Key provided by the iOS Provisioning Portal when registering the application" 
     }, 
     "defaultValue": "" 
     }, 
     "Apns.endpoint": { 
     "type": "string", 
     "metadata": { 
      "description": "The APNS endpoint to which our service connects. This is one of two values: gateway.sandbox.push.apple.com for the sandbox endpoint or gateway.push.apple.com, for the production endpoint. Any other value is invalid" 
     }, 
     "defaultValue": "gateway.sandbox.push.apple.com" 
     } 
    }, 
    "variables": { 
    "hubVersion": "[providers('Microsoft.NotificationHubs', 'namespaces').apiVersions[0]]", 
    "notificationHubNamespace": "[concat('hubv2', uniqueString(resourceGroup().id))]", 
    "notificationHubName": "notificationhub" 
    }, 
    "resources": [ 
    { 
     "name": "[variables('NotificationHubNamespace')]", 
     "location": "[resourceGroup().location]", 
     "type": "Microsoft.NotificationHubs/namespaces", 
     "apiVersion": "2017-04-01", 
     "comments": "Notification hub namespace", 
     "properties": { 
     "namespaceType": "NotificationHub" 
     }, 
     "resources": [ 
     { 
      "name": "[concat(variables('NotificationHubNamespace'),'/',variables('NotificationHubName'))]", 
      "location": "[resourceGroup().location]", 
      "type": "Microsoft.NotificationHubs/namespaces/notificationHubs", 
      "apiVersion": "2017-04-01", 
      "properties": { 
      "GcmCredential": { 
       "properties": { 
       "googleApiKey": "[parameters('Gcm.GoogleApiKey')]", 
       "gcmEndpoint": "https://android.googleapis.com/gcm/send" 
       } 
      }, 
      "apnsCredential": { 
       "properties": { 
        "apnsCertificate" : "[parameters('Apns.apnsCertificate')]", 
        "certificateKey" : "[parameters('Apns.certificateKey')]", 
        "endpoint" : "[parameters('Apns.endpoint')]" 
       } 
      } 
      }, 
      "dependsOn": [ 
      "[concat('Microsoft.NotificationHubs/namespaces/', variables('NotificationHubNamespace'))]" 
      ] 
     } 
     ] 
    } 
    ], 
    "outputs": { 
    } 
} 
+0

내가 속성 및 자격 증명을 제거하면 I 성공적으로 네임 스페이스와 허브를 만들 수 있습니다. 그러나 나는 어떻게 든 programatically 그들을 추가해야합니다. 사실 이후 또는이 템플릿의 일부로. –

답변

1

는 apsnCertificate 파일에서 base64로 문자열이며, certificatekey는 강력한 암호 할 필요가 인증서 암호입니다. 너도 같은거야?

또한 내부 오류 메시지가 표시됩니다. 그렇다면 무엇입니까?

감사합니다, 아몰

+0

base64로 변환해야하는 p12 파일 또는 pem 파일입니까? 문자 그대로 전체 파일을 byte []로 변환 한 다음 base64 문자열로 직렬화 한 것입니까? 다음 빈 암호를 지원하지 않는가? 나는 우리가 우리의 인증서에 넣어 생각하지 않습니다. 암호로 새 암호를 생성 해 볼 수 있습니다. 또한, 내면의 예외로 볼 수있는 것도 없었습니다. 상관 관계 ID를 사용하여 더 많은 정보를 볼 수 있는지 확실하지 않습니다. - 3faee649-7084-436d-8d7e-4a9c6f79cc4e –

+0

암호를 사용하여 .pem 파일을 사용하여 다시 시도했습니다. (암호를 추가하는 유일한 방법은 .pem 파일을 내보내는 것입니다). 나는 그 파일을 base64로 직렬화하여 5796 문자로 만든 다음 강력한 암호를 추가하여 (자동 생성 - devilries799538'epistemologists) 여전히 내부 예외없이 잘못된 요청을 받고 있습니다. –