gen-development-paa-cert.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2021 Project CHIP Authors
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. # Script that was used to generate CHIP Development Protuct Attestation Authority (PAA)
  18. # certificates.
  19. # The script expects the path to the chip-cert tool binary as an input argument.
  20. #
  21. # Usage example when the script is run from the CHIP SDK root directory:
  22. # ./credentials/development/gen-development-paa-cert.sh ./out/debug/standalone/chip-cert
  23. #
  24. # The result will be stored in:
  25. # credentials/development/attestation
  26. #
  27. set -e
  28. here=${0%/*}
  29. dest_dir="$here/attestation"
  30. mkdir -p "$dest_dir"
  31. if [ $# == 1 ]; then
  32. chip_cert_tool=$1
  33. else
  34. echo "Error: Please specify exactly one input argument; the path to the chip-cert tool binary"
  35. exit
  36. fi
  37. cert_valid_from="2021-06-28 14:23:43"
  38. cert_lifetime=4294967295
  39. paa_key_file="$dest_dir/Chip-Development-PAA-Key"
  40. paa_cert_file="$dest_dir/Chip-Development-PAA-Cert"
  41. "$chip_cert_tool" gen-att-cert --type a --subject-cn "Matter Development PAA" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --out-key "$paa_key_file".pem --out "$paa_cert_file".pem
  42. "$chip_cert_tool" convert-key "$paa_key_file".pem "$paa_key_file".der --x509-der
  43. "$chip_cert_tool" convert-cert "$paa_cert_file".pem "$paa_cert_file".der --x509-der
  44. # Example of how Vendor (FFF1) PAI Certificates can be generate:
  45. #
  46. # vid=FFF1
  47. # pai_key_file="$dest_dir/Chip-Development-PAI-$vid-Key"
  48. # pai_cert_file="$dest_dir/Chip-Development-PAI-$vid-Cert"
  49. #
  50. # "$chip_cert_tool" gen-att-cert --type i --subject-cn "Matter Development PAI" --subject-vid "$vid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --ca-key "$paa_key_file".pem --ca-cert "$paa_cert_file".pem --out-key "$pai_key_file".pem --out "$pai_cert_file".pem
  51. #
  52. # "$chip_cert_tool" convert-key "$pai_key_file".pem "$pai_key_file".der --x509-der
  53. # "$chip_cert_tool" convert-cert "$pai_cert_file".pem "$pai_cert_file".der --x509-der