main.swift 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2017, gRPC Authors All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import Foundation
  17. var s = ""
  18. s += "/*\n"
  19. s += " *\n"
  20. s += " * Copyright 2017, Google Inc.\n"
  21. s += " * All rights reserved.\n"
  22. s += " *\n"
  23. s += " * Redistribution and use in source and binary forms, with or without\n"
  24. s += " * modification, are permitted provided that the following conditions are\n"
  25. s += " * met:\n"
  26. s += " *\n"
  27. s += " * * Redistributions of source code must retain the above copyright\n"
  28. s += " * notice, this list of conditions and the following disclaimer.\n"
  29. s += " * * Redistributions in binary form must reproduce the above\n"
  30. s += " * copyright notice, this list of conditions and the following disclaimer\n"
  31. s += " * in the documentation and/or other materials provided with the\n"
  32. s += " * distribution.\n"
  33. s += " * * Neither the name of Google Inc. nor the names of its\n"
  34. s += " * contributors may be used to endorse or promote products derived from\n"
  35. s += " * this software without specific prior written permission.\n"
  36. s += " *\n"
  37. s += " * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n"
  38. s += " * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n"
  39. s += " * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n"
  40. s += " * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n"
  41. s += " * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n"
  42. s += " * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n"
  43. s += " * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n"
  44. s += " * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n"
  45. s += " * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
  46. s += " * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n"
  47. s += " * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  48. s += " *\n"
  49. s += " */\n"
  50. s += "// GENERATED: DO NOT EDIT\n"
  51. s += "//\n"
  52. s += "// This file contain a function that returns the default roots.pem.\n"
  53. s += "//\n"
  54. s += "import Foundation\n"
  55. s += "\n"
  56. s += "func roots_pem() -> String? {\n"
  57. let fileURL = URL(fileURLWithPath:"Assets/roots.pem")
  58. let filedata = try Data(contentsOf:fileURL)
  59. let encoding = filedata.base64EncodedString()
  60. s += " let roots = \n"
  61. s += " \"" + encoding + "\"\n"
  62. s += " if let data = Data(base64Encoded: roots, options:[]) {\n"
  63. s += " return String(data:data, encoding:.utf8)\n"
  64. s += " } else {\n"
  65. s += " return nil\n"
  66. s += " }\n"
  67. s += "}\n"
  68. print(s)