catocli 2.0.5__py3-none-any.whl → 2.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of catocli might be problematic. Click here for more details.

Files changed (365) hide show
  1. catocli/Utils/clidriver.py +32 -4
  2. catocli/Utils/version_checker.py +1 -1
  3. catocli/__init__.py +1 -1
  4. catocli/parsers/custom/export_sites/export_sites.py +18 -1
  5. catocli/parsers/custom/import_rules_to_tf/import_rules_to_tf.py +13 -2
  6. catocli/parsers/custom/import_sites_to_tf/__init__.py +3 -1
  7. catocli/parsers/custom/import_sites_to_tf/import_sites_to_tf.py +79 -6
  8. catocli/parsers/custom_private/__init__.py +134 -0
  9. catocli/parsers/mutation_accountManagement/__init__.py +13 -0
  10. catocli/parsers/mutation_accountManagement_disableAccount/README.md +16 -0
  11. catocli/parsers/mutation_groups/README.md +7 -0
  12. catocli/parsers/mutation_groups/__init__.py +48 -0
  13. catocli/parsers/mutation_groups_createGroup/README.md +18 -0
  14. catocli/parsers/mutation_groups_deleteGroup/README.md +18 -0
  15. catocli/parsers/mutation_groups_updateGroup/README.md +18 -0
  16. catocli/parsers/mutation_site/__init__.py +104 -0
  17. catocli/parsers/mutation_site_assignSiteBwLicense/README.md +17 -0
  18. catocli/parsers/mutation_site_removeSecondaryAwsVSocket/README.md +17 -0
  19. catocli/parsers/mutation_site_removeSecondaryAzureVSocket/README.md +17 -0
  20. catocli/parsers/mutation_site_removeSiteBwLicense/README.md +17 -0
  21. catocli/parsers/mutation_site_replaceSiteBwLicense/README.md +17 -0
  22. catocli/parsers/mutation_site_updateSecondaryAwsVSocket/README.md +17 -0
  23. catocli/parsers/mutation_site_updateSecondaryAzureVSocket/README.md +17 -0
  24. catocli/parsers/mutation_site_updateSiteBwLicense/README.md +17 -0
  25. catocli/parsers/mutation_site_updateSiteGeneralDetails/README.md +1 -1
  26. catocli/parsers/mutation_sites/__init__.py +104 -0
  27. catocli/parsers/mutation_sites_assignSiteBwLicense/README.md +17 -0
  28. catocli/parsers/mutation_sites_removeSecondaryAwsVSocket/README.md +17 -0
  29. catocli/parsers/mutation_sites_removeSecondaryAzureVSocket/README.md +17 -0
  30. catocli/parsers/mutation_sites_removeSiteBwLicense/README.md +17 -0
  31. catocli/parsers/mutation_sites_replaceSiteBwLicense/README.md +17 -0
  32. catocli/parsers/mutation_sites_updateSecondaryAwsVSocket/README.md +17 -0
  33. catocli/parsers/mutation_sites_updateSecondaryAzureVSocket/README.md +17 -0
  34. catocli/parsers/mutation_sites_updateSiteBwLicense/README.md +17 -0
  35. catocli/parsers/mutation_sites_updateSiteGeneralDetails/README.md +1 -1
  36. catocli/parsers/parserApiClient.py +444 -9
  37. catocli/parsers/query_eventsFeed/README.md +1 -1
  38. catocli/parsers/query_groups/README.md +7 -0
  39. catocli/parsers/query_groups/__init__.py +54 -0
  40. catocli/parsers/query_groups_group/README.md +7 -0
  41. catocli/parsers/query_groups_groupList/README.md +18 -0
  42. catocli/parsers/query_groups_group_members/README.md +18 -0
  43. catocli/parsers/query_groups_whereUsed/README.md +17 -0
  44. catocli/parsers/query_popLocations/README.md +17 -0
  45. catocli/parsers/query_popLocations/__init__.py +16 -0
  46. catocli/parsers/query_site/__init__.py +26 -0
  47. catocli/parsers/query_site_secondaryAwsVSocket/README.md +17 -0
  48. catocli/parsers/query_site_secondaryAzureVSocket/README.md +17 -0
  49. catocli/parsers/query_socketPortMetrics/README.md +23 -0
  50. catocli/parsers/query_socketPortMetrics/__init__.py +16 -0
  51. catocli/parsers/query_socketPortMetricsTimeSeries/README.md +24 -0
  52. catocli/parsers/query_socketPortMetricsTimeSeries/__init__.py +16 -0
  53. {catocli-2.0.5.dist-info → catocli-2.1.1.dist-info}/METADATA +3 -2
  54. {catocli-2.0.5.dist-info → catocli-2.1.1.dist-info}/RECORD +253 -300
  55. {catocli-2.0.5.dist-info → catocli-2.1.1.dist-info}/WHEEL +1 -1
  56. {catocli-2.0.5.dist-info → catocli-2.1.1.dist-info}/top_level.txt +0 -2
  57. graphql_client/api/call_api.py +20 -2
  58. models/mutation.accountManagement.addAccount.json +97 -0
  59. models/mutation.accountManagement.disableAccount.json +545 -0
  60. models/mutation.accountManagement.removeAccount.json +102 -3
  61. models/mutation.accountManagement.updateAccount.json +97 -0
  62. models/mutation.admin.addAdmin.json +6 -9
  63. models/mutation.container.delete.json +2 -2
  64. models/mutation.container.fqdn.addValues.json +3 -3
  65. models/mutation.container.fqdn.createFromFile.json +3 -3
  66. models/mutation.container.fqdn.removeValues.json +3 -3
  67. models/mutation.container.fqdn.updateFromFile.json +3 -3
  68. models/mutation.container.ipAddressRange.addValues.json +3 -3
  69. models/mutation.container.ipAddressRange.createFromFile.json +3 -3
  70. models/mutation.container.ipAddressRange.removeValues.json +3 -3
  71. models/mutation.container.ipAddressRange.updateFromFile.json +3 -3
  72. models/mutation.groups.createGroup.json +3178 -0
  73. models/mutation.groups.deleteGroup.json +2758 -0
  74. models/mutation.groups.updateGroup.json +4429 -0
  75. models/mutation.hardware.updateHardwareShipping.json +30 -10
  76. models/mutation.policy.appTenantRestriction.addRule.json +33 -33
  77. models/mutation.policy.appTenantRestriction.addSection.json +4 -4
  78. models/mutation.policy.appTenantRestriction.createPolicyRevision.json +33 -33
  79. models/mutation.policy.appTenantRestriction.discardPolicyRevision.json +33 -33
  80. models/mutation.policy.appTenantRestriction.moveRule.json +27 -27
  81. models/mutation.policy.appTenantRestriction.moveSection.json +4 -4
  82. models/mutation.policy.appTenantRestriction.publishPolicyRevision.json +33 -33
  83. models/mutation.policy.appTenantRestriction.removeRule.json +27 -27
  84. models/mutation.policy.appTenantRestriction.removeSection.json +4 -4
  85. models/mutation.policy.appTenantRestriction.updatePolicy.json +33 -33
  86. models/mutation.policy.appTenantRestriction.updateRule.json +33 -33
  87. models/mutation.policy.appTenantRestriction.updateSection.json +4 -4
  88. models/mutation.policy.dynamicIpAllocation.addRule.json +12 -12
  89. models/mutation.policy.dynamicIpAllocation.addSection.json +4 -4
  90. models/mutation.policy.dynamicIpAllocation.createPolicyRevision.json +18 -18
  91. models/mutation.policy.dynamicIpAllocation.discardPolicyRevision.json +18 -18
  92. models/mutation.policy.dynamicIpAllocation.moveRule.json +12 -12
  93. models/mutation.policy.dynamicIpAllocation.moveSection.json +4 -4
  94. models/mutation.policy.dynamicIpAllocation.publishPolicyRevision.json +18 -18
  95. models/mutation.policy.dynamicIpAllocation.removeRule.json +12 -12
  96. models/mutation.policy.dynamicIpAllocation.removeSection.json +4 -4
  97. models/mutation.policy.dynamicIpAllocation.updatePolicy.json +18 -18
  98. models/mutation.policy.dynamicIpAllocation.updateRule.json +12 -12
  99. models/mutation.policy.dynamicIpAllocation.updateSection.json +4 -4
  100. models/mutation.policy.internetFirewall.addRule.json +141 -141
  101. models/mutation.policy.internetFirewall.addSection.json +4 -4
  102. models/mutation.policy.internetFirewall.createPolicyRevision.json +102 -102
  103. models/mutation.policy.internetFirewall.discardPolicyRevision.json +102 -102
  104. models/mutation.policy.internetFirewall.moveRule.json +96 -96
  105. models/mutation.policy.internetFirewall.moveSection.json +4 -4
  106. models/mutation.policy.internetFirewall.publishPolicyRevision.json +102 -102
  107. models/mutation.policy.internetFirewall.removeRule.json +96 -96
  108. models/mutation.policy.internetFirewall.removeSection.json +4 -4
  109. models/mutation.policy.internetFirewall.updatePolicy.json +102 -102
  110. models/mutation.policy.internetFirewall.updateRule.json +141 -141
  111. models/mutation.policy.internetFirewall.updateSection.json +4 -4
  112. models/mutation.policy.remotePortFwd.addRule.json +21 -21
  113. models/mutation.policy.remotePortFwd.addSection.json +4 -4
  114. models/mutation.policy.remotePortFwd.createPolicyRevision.json +24 -24
  115. models/mutation.policy.remotePortFwd.discardPolicyRevision.json +24 -24
  116. models/mutation.policy.remotePortFwd.moveRule.json +18 -18
  117. models/mutation.policy.remotePortFwd.moveSection.json +4 -4
  118. models/mutation.policy.remotePortFwd.publishPolicyRevision.json +24 -24
  119. models/mutation.policy.remotePortFwd.removeRule.json +18 -18
  120. models/mutation.policy.remotePortFwd.removeSection.json +4 -4
  121. models/mutation.policy.remotePortFwd.updatePolicy.json +24 -24
  122. models/mutation.policy.remotePortFwd.updateRule.json +21 -21
  123. models/mutation.policy.remotePortFwd.updateSection.json +4 -4
  124. models/mutation.policy.socketLan.addRule.json +97 -97
  125. models/mutation.policy.socketLan.addSection.json +4 -4
  126. models/mutation.policy.socketLan.createPolicyRevision.json +91 -91
  127. models/mutation.policy.socketLan.discardPolicyRevision.json +91 -91
  128. models/mutation.policy.socketLan.moveRule.json +85 -85
  129. models/mutation.policy.socketLan.moveSection.json +4 -4
  130. models/mutation.policy.socketLan.publishPolicyRevision.json +91 -91
  131. models/mutation.policy.socketLan.removeRule.json +85 -85
  132. models/mutation.policy.socketLan.removeSection.json +4 -4
  133. models/mutation.policy.socketLan.updatePolicy.json +91 -91
  134. models/mutation.policy.socketLan.updateRule.json +97 -97
  135. models/mutation.policy.socketLan.updateSection.json +4 -4
  136. models/mutation.policy.terminalServer.addRule.json +7 -7
  137. models/mutation.policy.terminalServer.addSection.json +4 -4
  138. models/mutation.policy.terminalServer.createPolicyRevision.json +13 -13
  139. models/mutation.policy.terminalServer.discardPolicyRevision.json +13 -13
  140. models/mutation.policy.terminalServer.moveRule.json +7 -7
  141. models/mutation.policy.terminalServer.moveSection.json +4 -4
  142. models/mutation.policy.terminalServer.publishPolicyRevision.json +13 -13
  143. models/mutation.policy.terminalServer.removeRule.json +7 -7
  144. models/mutation.policy.terminalServer.removeSection.json +4 -4
  145. models/mutation.policy.terminalServer.updatePolicy.json +13 -13
  146. models/mutation.policy.terminalServer.updateRule.json +7 -7
  147. models/mutation.policy.terminalServer.updateSection.json +4 -4
  148. models/mutation.policy.wanFirewall.addRule.json +157 -157
  149. models/mutation.policy.wanFirewall.addSection.json +4 -4
  150. models/mutation.policy.wanFirewall.createPolicyRevision.json +121 -121
  151. models/mutation.policy.wanFirewall.discardPolicyRevision.json +121 -121
  152. models/mutation.policy.wanFirewall.moveRule.json +115 -115
  153. models/mutation.policy.wanFirewall.moveSection.json +4 -4
  154. models/mutation.policy.wanFirewall.publishPolicyRevision.json +121 -121
  155. models/mutation.policy.wanFirewall.removeRule.json +115 -115
  156. models/mutation.policy.wanFirewall.removeSection.json +4 -4
  157. models/mutation.policy.wanFirewall.updatePolicy.json +121 -121
  158. models/mutation.policy.wanFirewall.updateRule.json +157 -157
  159. models/mutation.policy.wanFirewall.updateSection.json +4 -4
  160. models/mutation.policy.wanNetwork.addRule.json +103 -103
  161. models/mutation.policy.wanNetwork.addSection.json +4 -4
  162. models/mutation.policy.wanNetwork.createPolicyRevision.json +97 -97
  163. models/mutation.policy.wanNetwork.discardPolicyRevision.json +97 -97
  164. models/mutation.policy.wanNetwork.moveRule.json +91 -91
  165. models/mutation.policy.wanNetwork.moveSection.json +4 -4
  166. models/mutation.policy.wanNetwork.publishPolicyRevision.json +97 -97
  167. models/mutation.policy.wanNetwork.removeRule.json +91 -91
  168. models/mutation.policy.wanNetwork.removeSection.json +4 -4
  169. models/mutation.policy.wanNetwork.updatePolicy.json +97 -97
  170. models/mutation.policy.wanNetwork.updateRule.json +103 -103
  171. models/mutation.policy.wanNetwork.updateSection.json +4 -4
  172. models/mutation.site.addBgpPeer.json +10 -10
  173. models/mutation.site.addIpsecIkeV2SiteTunnels.json +2 -2
  174. models/mutation.site.addSocketAddOnCard.json +2 -2
  175. models/mutation.site.assignSiteBwLicense.json +12879 -0
  176. models/mutation.site.removeBgpPeer.json +10 -10
  177. models/mutation.site.removeIpsecIkeV2SiteTunnels.json +2 -2
  178. models/mutation.site.removeSecondaryAwsVSocket.json +375 -0
  179. models/mutation.site.removeSecondaryAzureVSocket.json +354 -0
  180. models/mutation.site.removeSiteBwLicense.json +12822 -0
  181. models/mutation.site.removeSocketAddOnCard.json +2 -2
  182. models/mutation.site.replaceSiteBwLicense.json +12939 -0
  183. models/mutation.site.startSiteUpgrade.json +36 -15
  184. models/mutation.site.updateBgpPeer.json +10 -10
  185. models/mutation.site.updateIpsecIkeV2SiteTunnels.json +2 -2
  186. models/mutation.site.updateSecondaryAwsVSocket.json +643 -0
  187. models/mutation.site.updateSecondaryAzureVSocket.json +565 -0
  188. models/mutation.site.updateSiteBwLicense.json +12882 -0
  189. models/mutation.site.updateSiteGeneralDetails.json +724 -1
  190. models/mutation.sites.addBgpPeer.json +10 -10
  191. models/mutation.sites.addIpsecIkeV2SiteTunnels.json +2 -2
  192. models/mutation.sites.addSocketAddOnCard.json +2 -2
  193. models/mutation.sites.assignSiteBwLicense.json +12879 -0
  194. models/mutation.sites.removeBgpPeer.json +10 -10
  195. models/mutation.sites.removeIpsecIkeV2SiteTunnels.json +2 -2
  196. models/mutation.sites.removeSecondaryAwsVSocket.json +375 -0
  197. models/mutation.sites.removeSecondaryAzureVSocket.json +354 -0
  198. models/mutation.sites.removeSiteBwLicense.json +12822 -0
  199. models/mutation.sites.removeSocketAddOnCard.json +2 -2
  200. models/mutation.sites.replaceSiteBwLicense.json +12939 -0
  201. models/mutation.sites.startSiteUpgrade.json +36 -15
  202. models/mutation.sites.updateBgpPeer.json +10 -10
  203. models/mutation.sites.updateIpsecIkeV2SiteTunnels.json +2 -2
  204. models/mutation.sites.updateSecondaryAwsVSocket.json +643 -0
  205. models/mutation.sites.updateSecondaryAzureVSocket.json +565 -0
  206. models/mutation.sites.updateSiteBwLicense.json +12882 -0
  207. models/mutation.sites.updateSiteGeneralDetails.json +724 -1
  208. models/mutation.xdr.addStoryComment.json +1 -1
  209. models/mutation.xdr.analystFeedback.json +84 -84
  210. models/mutation.xdr.deleteStoryComment.json +1 -1
  211. models/query.accountManagement.json +97 -0
  212. models/query.accountMetrics.json +45 -45
  213. models/query.accountSnapshot.json +30 -30
  214. models/query.admin.json +6 -6
  215. models/query.admins.json +13 -13
  216. models/query.appStats.json +915 -867
  217. models/query.appStatsTimeSeries.json +692 -656
  218. models/query.auditFeed.json +6 -6
  219. models/query.catalogs.json +52 -52
  220. models/query.container.json +16 -16
  221. models/query.devices.json +20 -93
  222. models/query.entityLookup.json +2 -2
  223. models/query.events.json +288 -384
  224. models/query.eventsFeed.json +73 -97
  225. models/query.eventsTimeSeries.json +219 -291
  226. models/query.groups.group.members.json +3058 -0
  227. models/query.groups.groupList.json +6474 -0
  228. models/query.groups.whereUsed.json +697 -0
  229. models/query.hardware.json +27 -7
  230. models/query.hardwareManagement.json +8 -8
  231. models/query.licensing.json +3487 -1324
  232. models/query.policy.appTenantRestriction.policy.json +32 -32
  233. models/query.policy.dynamicIpAllocation.policy.json +18 -18
  234. models/query.policy.internetFirewall.policy.json +93 -93
  235. models/query.policy.remotePortFwd.policy.json +23 -23
  236. models/query.policy.socketLan.policy.json +88 -88
  237. models/query.policy.terminalServer.policy.json +13 -13
  238. models/query.policy.wanFirewall.policy.json +111 -111
  239. models/query.policy.wanNetwork.policy.json +97 -97
  240. models/query.popLocations.json +2878 -0
  241. models/query.sandbox.json +5 -5
  242. models/query.site.bgpPeer.json +4 -4
  243. models/query.site.bgpPeerList.json +10 -10
  244. models/query.site.secondaryAwsVSocket.json +340 -0
  245. models/query.site.secondaryAzureVSocket.json +319 -0
  246. models/query.site.siteBgpStatus.json +2 -2
  247. models/query.socketPortMetrics.json +2410 -0
  248. models/query.socketPortMetricsTimeSeries.json +2361 -0
  249. models/query.xdr.stories.json +104 -104
  250. models/query.xdr.story.json +93 -93
  251. schema/catolib.py +43 -16
  252. build/lib/catocli/Utils/clidriver.py +0 -268
  253. build/lib/catocli/Utils/profile_manager.py +0 -188
  254. build/lib/catocli/Utils/version_checker.py +0 -192
  255. build/lib/catocli/__init__.py +0 -2
  256. build/lib/catocli/__main__.py +0 -12
  257. build/lib/catocli/parsers/configure/__init__.py +0 -115
  258. build/lib/catocli/parsers/configure/configure.py +0 -307
  259. build/lib/catocli/parsers/custom/__init__.py +0 -57
  260. build/lib/catocli/parsers/custom/customLib.py +0 -561
  261. build/lib/catocli/parsers/custom/export_rules/__init__.py +0 -42
  262. build/lib/catocli/parsers/custom/export_rules/export_rules.py +0 -234
  263. build/lib/catocli/parsers/custom/export_sites/__init__.py +0 -21
  264. build/lib/catocli/parsers/custom/export_sites/export_sites.py +0 -372
  265. build/lib/catocli/parsers/custom/import_rules_to_tf/__init__.py +0 -58
  266. build/lib/catocli/parsers/custom/import_rules_to_tf/import_rules_to_tf.py +0 -451
  267. build/lib/catocli/parsers/custom/import_sites_to_tf/__init__.py +0 -45
  268. build/lib/catocli/parsers/custom/import_sites_to_tf/import_sites_to_tf.py +0 -891
  269. build/lib/catocli/parsers/mutation_accountManagement/__init__.py +0 -48
  270. build/lib/catocli/parsers/mutation_admin/__init__.py +0 -48
  271. build/lib/catocli/parsers/mutation_container/__init__.py +0 -138
  272. build/lib/catocli/parsers/mutation_hardware/__init__.py +0 -22
  273. build/lib/catocli/parsers/mutation_policy/__init__.py +0 -1305
  274. build/lib/catocli/parsers/mutation_sandbox/__init__.py +0 -35
  275. build/lib/catocli/parsers/mutation_site/__init__.py +0 -373
  276. build/lib/catocli/parsers/mutation_sites/__init__.py +0 -373
  277. build/lib/catocli/parsers/mutation_xdr/__init__.py +0 -48
  278. build/lib/catocli/parsers/parserApiClient.py +0 -513
  279. build/lib/catocli/parsers/query_accountBySubdomain/__init__.py +0 -16
  280. build/lib/catocli/parsers/query_accountManagement/__init__.py +0 -16
  281. build/lib/catocli/parsers/query_accountMetrics/__init__.py +0 -16
  282. build/lib/catocli/parsers/query_accountRoles/__init__.py +0 -16
  283. build/lib/catocli/parsers/query_accountSnapshot/__init__.py +0 -16
  284. build/lib/catocli/parsers/query_admin/__init__.py +0 -16
  285. build/lib/catocli/parsers/query_admins/__init__.py +0 -16
  286. build/lib/catocli/parsers/query_appStats/__init__.py +0 -16
  287. build/lib/catocli/parsers/query_appStatsTimeSeries/__init__.py +0 -16
  288. build/lib/catocli/parsers/query_auditFeed/__init__.py +0 -16
  289. build/lib/catocli/parsers/query_catalogs/__init__.py +0 -16
  290. build/lib/catocli/parsers/query_container/__init__.py +0 -16
  291. build/lib/catocli/parsers/query_devices/__init__.py +0 -16
  292. build/lib/catocli/parsers/query_entityLookup/__init__.py +0 -16
  293. build/lib/catocli/parsers/query_events/__init__.py +0 -16
  294. build/lib/catocli/parsers/query_eventsFeed/__init__.py +0 -16
  295. build/lib/catocli/parsers/query_eventsTimeSeries/__init__.py +0 -16
  296. build/lib/catocli/parsers/query_hardware/__init__.py +0 -16
  297. build/lib/catocli/parsers/query_hardwareManagement/__init__.py +0 -16
  298. build/lib/catocli/parsers/query_licensing/__init__.py +0 -16
  299. build/lib/catocli/parsers/query_policy/__init__.py +0 -161
  300. build/lib/catocli/parsers/query_sandbox/__init__.py +0 -16
  301. build/lib/catocli/parsers/query_site/__init__.py +0 -100
  302. build/lib/catocli/parsers/query_siteLocation/__init__.py +0 -13
  303. build/lib/catocli/parsers/query_subDomains/__init__.py +0 -16
  304. build/lib/catocli/parsers/query_xdr/__init__.py +0 -35
  305. build/lib/catocli/parsers/raw/__init__.py +0 -12
  306. build/lib/graphql_client/__init__.py +0 -11
  307. build/lib/graphql_client/api/__init__.py +0 -3
  308. build/lib/graphql_client/api/call_api.py +0 -84
  309. build/lib/graphql_client/api_client.py +0 -192
  310. build/lib/graphql_client/api_client_types.py +0 -409
  311. build/lib/graphql_client/configuration.py +0 -232
  312. build/lib/graphql_client/models/__init__.py +0 -13
  313. build/lib/graphql_client/models/no_schema.py +0 -71
  314. build/lib/schema/catolib.py +0 -1141
  315. build/lib/schema/importSchema.py +0 -60
  316. build/lib/schema/remove_policyid.py +0 -89
  317. build/lib/schema/remove_policyid_mutations.py +0 -89
  318. build/lib/scripts/catolib.py +0 -62
  319. build/lib/scripts/export_if_rules_to_json.py +0 -188
  320. build/lib/scripts/export_wf_rules_to_json.py +0 -111
  321. build/lib/scripts/import_wf_rules_to_tfstate.py +0 -331
  322. build/lib/vendor/certifi/__init__.py +0 -4
  323. build/lib/vendor/certifi/__main__.py +0 -12
  324. build/lib/vendor/certifi/core.py +0 -114
  325. build/lib/vendor/certifi/py.typed +0 -0
  326. build/lib/vendor/six.py +0 -998
  327. build/lib/vendor/urllib3/__init__.py +0 -211
  328. build/lib/vendor/urllib3/_base_connection.py +0 -172
  329. build/lib/vendor/urllib3/_collections.py +0 -483
  330. build/lib/vendor/urllib3/_request_methods.py +0 -278
  331. build/lib/vendor/urllib3/_version.py +0 -16
  332. build/lib/vendor/urllib3/connection.py +0 -1033
  333. build/lib/vendor/urllib3/connectionpool.py +0 -1182
  334. build/lib/vendor/urllib3/contrib/__init__.py +0 -0
  335. build/lib/vendor/urllib3/contrib/emscripten/__init__.py +0 -18
  336. build/lib/vendor/urllib3/contrib/emscripten/connection.py +0 -254
  337. build/lib/vendor/urllib3/contrib/emscripten/fetch.py +0 -418
  338. build/lib/vendor/urllib3/contrib/emscripten/request.py +0 -22
  339. build/lib/vendor/urllib3/contrib/emscripten/response.py +0 -285
  340. build/lib/vendor/urllib3/contrib/pyopenssl.py +0 -552
  341. build/lib/vendor/urllib3/contrib/socks.py +0 -228
  342. build/lib/vendor/urllib3/exceptions.py +0 -321
  343. build/lib/vendor/urllib3/fields.py +0 -341
  344. build/lib/vendor/urllib3/filepost.py +0 -89
  345. build/lib/vendor/urllib3/http2/__init__.py +0 -53
  346. build/lib/vendor/urllib3/http2/connection.py +0 -356
  347. build/lib/vendor/urllib3/http2/probe.py +0 -87
  348. build/lib/vendor/urllib3/poolmanager.py +0 -637
  349. build/lib/vendor/urllib3/py.typed +0 -2
  350. build/lib/vendor/urllib3/response.py +0 -1265
  351. build/lib/vendor/urllib3/util/__init__.py +0 -42
  352. build/lib/vendor/urllib3/util/connection.py +0 -137
  353. build/lib/vendor/urllib3/util/proxy.py +0 -43
  354. build/lib/vendor/urllib3/util/request.py +0 -256
  355. build/lib/vendor/urllib3/util/response.py +0 -101
  356. build/lib/vendor/urllib3/util/retry.py +0 -533
  357. build/lib/vendor/urllib3/util/ssl_.py +0 -513
  358. build/lib/vendor/urllib3/util/ssl_match_hostname.py +0 -159
  359. build/lib/vendor/urllib3/util/ssltransport.py +0 -276
  360. build/lib/vendor/urllib3/util/timeout.py +0 -275
  361. build/lib/vendor/urllib3/util/url.py +0 -471
  362. build/lib/vendor/urllib3/util/util.py +0 -42
  363. build/lib/vendor/urllib3/util/wait.py +0 -124
  364. {catocli-2.0.5.dist-info → catocli-2.1.1.dist-info}/entry_points.txt +0 -0
  365. {catocli-2.0.5.dist-info → catocli-2.1.1.dist-info/licenses}/LICENSE +0 -0
@@ -1,552 +0,0 @@
1
- """
2
- Module for using pyOpenSSL as a TLS backend. This module was relevant before
3
- the standard library ``ssl`` module supported SNI, but now that we've dropped
4
- support for Python 2.7 all relevant Python versions support SNI so
5
- **this module is no longer recommended**.
6
-
7
- This needs the following packages installed:
8
-
9
- * `pyOpenSSL`_ (tested with 16.0.0)
10
- * `cryptography`_ (minimum 1.3.4, from pyopenssl)
11
- * `idna`_ (minimum 2.0)
12
-
13
- However, pyOpenSSL depends on cryptography, so while we use all three directly here we
14
- end up having relatively few packages required.
15
-
16
- You can install them with the following command:
17
-
18
- .. code-block:: bash
19
-
20
- $ python -m pip install pyopenssl cryptography idna
21
-
22
- To activate certificate checking, call
23
- :func:`~urllib3.contrib.pyopenssl.inject_into_urllib3` from your Python code
24
- before you begin making HTTP requests. This can be done in a ``sitecustomize``
25
- module, or at any other time before your application begins using ``urllib3``,
26
- like this:
27
-
28
- .. code-block:: python
29
-
30
- try:
31
- import urllib3.contrib.pyopenssl
32
- urllib3.contrib.pyopenssl.inject_into_urllib3()
33
- except ImportError:
34
- pass
35
-
36
- .. _pyopenssl: https://www.pyopenssl.org
37
- .. _cryptography: https://cryptography.io
38
- .. _idna: https://github.com/kjd/idna
39
- """
40
-
41
- from __future__ import annotations
42
-
43
- import OpenSSL.SSL # type: ignore[import-untyped]
44
- from cryptography import x509
45
-
46
- try:
47
- from cryptography.x509 import UnsupportedExtension # type: ignore[attr-defined]
48
- except ImportError:
49
- # UnsupportedExtension is gone in cryptography >= 2.1.0
50
- class UnsupportedExtension(Exception): # type: ignore[no-redef]
51
- pass
52
-
53
-
54
- import logging
55
- import ssl
56
- import typing
57
- from io import BytesIO
58
- from socket import socket as socket_cls
59
- from socket import timeout
60
-
61
- from .. import util
62
-
63
- if typing.TYPE_CHECKING:
64
- from OpenSSL.crypto import X509 # type: ignore[import-untyped]
65
-
66
-
67
- __all__ = ["inject_into_urllib3", "extract_from_urllib3"]
68
-
69
- # Map from urllib3 to PyOpenSSL compatible parameter-values.
70
- _openssl_versions: dict[int, int] = {
71
- util.ssl_.PROTOCOL_TLS: OpenSSL.SSL.SSLv23_METHOD, # type: ignore[attr-defined]
72
- util.ssl_.PROTOCOL_TLS_CLIENT: OpenSSL.SSL.SSLv23_METHOD, # type: ignore[attr-defined]
73
- ssl.PROTOCOL_TLSv1: OpenSSL.SSL.TLSv1_METHOD,
74
- }
75
-
76
- if hasattr(ssl, "PROTOCOL_TLSv1_1") and hasattr(OpenSSL.SSL, "TLSv1_1_METHOD"):
77
- _openssl_versions[ssl.PROTOCOL_TLSv1_1] = OpenSSL.SSL.TLSv1_1_METHOD
78
-
79
- if hasattr(ssl, "PROTOCOL_TLSv1_2") and hasattr(OpenSSL.SSL, "TLSv1_2_METHOD"):
80
- _openssl_versions[ssl.PROTOCOL_TLSv1_2] = OpenSSL.SSL.TLSv1_2_METHOD
81
-
82
-
83
- _stdlib_to_openssl_verify = {
84
- ssl.CERT_NONE: OpenSSL.SSL.VERIFY_NONE,
85
- ssl.CERT_OPTIONAL: OpenSSL.SSL.VERIFY_PEER,
86
- ssl.CERT_REQUIRED: OpenSSL.SSL.VERIFY_PEER
87
- + OpenSSL.SSL.VERIFY_FAIL_IF_NO_PEER_CERT,
88
- }
89
- _openssl_to_stdlib_verify = {v: k for k, v in _stdlib_to_openssl_verify.items()}
90
-
91
- # The SSLvX values are the most likely to be missing in the future
92
- # but we check them all just to be sure.
93
- _OP_NO_SSLv2_OR_SSLv3: int = getattr(OpenSSL.SSL, "OP_NO_SSLv2", 0) | getattr(
94
- OpenSSL.SSL, "OP_NO_SSLv3", 0
95
- )
96
- _OP_NO_TLSv1: int = getattr(OpenSSL.SSL, "OP_NO_TLSv1", 0)
97
- _OP_NO_TLSv1_1: int = getattr(OpenSSL.SSL, "OP_NO_TLSv1_1", 0)
98
- _OP_NO_TLSv1_2: int = getattr(OpenSSL.SSL, "OP_NO_TLSv1_2", 0)
99
- _OP_NO_TLSv1_3: int = getattr(OpenSSL.SSL, "OP_NO_TLSv1_3", 0)
100
-
101
- _openssl_to_ssl_minimum_version: dict[int, int] = {
102
- ssl.TLSVersion.MINIMUM_SUPPORTED: _OP_NO_SSLv2_OR_SSLv3,
103
- ssl.TLSVersion.TLSv1: _OP_NO_SSLv2_OR_SSLv3,
104
- ssl.TLSVersion.TLSv1_1: _OP_NO_SSLv2_OR_SSLv3 | _OP_NO_TLSv1,
105
- ssl.TLSVersion.TLSv1_2: _OP_NO_SSLv2_OR_SSLv3 | _OP_NO_TLSv1 | _OP_NO_TLSv1_1,
106
- ssl.TLSVersion.TLSv1_3: (
107
- _OP_NO_SSLv2_OR_SSLv3 | _OP_NO_TLSv1 | _OP_NO_TLSv1_1 | _OP_NO_TLSv1_2
108
- ),
109
- ssl.TLSVersion.MAXIMUM_SUPPORTED: (
110
- _OP_NO_SSLv2_OR_SSLv3 | _OP_NO_TLSv1 | _OP_NO_TLSv1_1 | _OP_NO_TLSv1_2
111
- ),
112
- }
113
- _openssl_to_ssl_maximum_version: dict[int, int] = {
114
- ssl.TLSVersion.MINIMUM_SUPPORTED: (
115
- _OP_NO_SSLv2_OR_SSLv3
116
- | _OP_NO_TLSv1
117
- | _OP_NO_TLSv1_1
118
- | _OP_NO_TLSv1_2
119
- | _OP_NO_TLSv1_3
120
- ),
121
- ssl.TLSVersion.TLSv1: (
122
- _OP_NO_SSLv2_OR_SSLv3 | _OP_NO_TLSv1_1 | _OP_NO_TLSv1_2 | _OP_NO_TLSv1_3
123
- ),
124
- ssl.TLSVersion.TLSv1_1: _OP_NO_SSLv2_OR_SSLv3 | _OP_NO_TLSv1_2 | _OP_NO_TLSv1_3,
125
- ssl.TLSVersion.TLSv1_2: _OP_NO_SSLv2_OR_SSLv3 | _OP_NO_TLSv1_3,
126
- ssl.TLSVersion.TLSv1_3: _OP_NO_SSLv2_OR_SSLv3,
127
- ssl.TLSVersion.MAXIMUM_SUPPORTED: _OP_NO_SSLv2_OR_SSLv3,
128
- }
129
-
130
- # OpenSSL will only write 16K at a time
131
- SSL_WRITE_BLOCKSIZE = 16384
132
-
133
- orig_util_SSLContext = util.ssl_.SSLContext
134
-
135
-
136
- log = logging.getLogger(__name__)
137
-
138
-
139
- def inject_into_urllib3() -> None:
140
- "Monkey-patch urllib3 with PyOpenSSL-backed SSL-support."
141
-
142
- _validate_dependencies_met()
143
-
144
- util.SSLContext = PyOpenSSLContext # type: ignore[assignment]
145
- util.ssl_.SSLContext = PyOpenSSLContext # type: ignore[assignment]
146
- util.IS_PYOPENSSL = True
147
- util.ssl_.IS_PYOPENSSL = True
148
-
149
-
150
- def extract_from_urllib3() -> None:
151
- "Undo monkey-patching by :func:`inject_into_urllib3`."
152
-
153
- util.SSLContext = orig_util_SSLContext
154
- util.ssl_.SSLContext = orig_util_SSLContext
155
- util.IS_PYOPENSSL = False
156
- util.ssl_.IS_PYOPENSSL = False
157
-
158
-
159
- def _validate_dependencies_met() -> None:
160
- """
161
- Verifies that PyOpenSSL's package-level dependencies have been met.
162
- Throws `ImportError` if they are not met.
163
- """
164
- # Method added in `cryptography==1.1`; not available in older versions
165
- from cryptography.x509.extensions import Extensions
166
-
167
- if getattr(Extensions, "get_extension_for_class", None) is None:
168
- raise ImportError(
169
- "'cryptography' module missing required functionality. "
170
- "Try upgrading to v1.3.4 or newer."
171
- )
172
-
173
- # pyOpenSSL 0.14 and above use cryptography for OpenSSL bindings. The _x509
174
- # attribute is only present on those versions.
175
- from OpenSSL.crypto import X509
176
-
177
- x509 = X509()
178
- if getattr(x509, "_x509", None) is None:
179
- raise ImportError(
180
- "'pyOpenSSL' module missing required functionality. "
181
- "Try upgrading to v0.14 or newer."
182
- )
183
-
184
-
185
- def _dnsname_to_stdlib(name: str) -> str | None:
186
- """
187
- Converts a dNSName SubjectAlternativeName field to the form used by the
188
- standard library on the given Python version.
189
-
190
- Cryptography produces a dNSName as a unicode string that was idna-decoded
191
- from ASCII bytes. We need to idna-encode that string to get it back, and
192
- then on Python 3 we also need to convert to unicode via UTF-8 (the stdlib
193
- uses PyUnicode_FromStringAndSize on it, which decodes via UTF-8).
194
-
195
- If the name cannot be idna-encoded then we return None signalling that
196
- the name given should be skipped.
197
- """
198
-
199
- def idna_encode(name: str) -> bytes | None:
200
- """
201
- Borrowed wholesale from the Python Cryptography Project. It turns out
202
- that we can't just safely call `idna.encode`: it can explode for
203
- wildcard names. This avoids that problem.
204
- """
205
- import idna
206
-
207
- try:
208
- for prefix in ["*.", "."]:
209
- if name.startswith(prefix):
210
- name = name[len(prefix) :]
211
- return prefix.encode("ascii") + idna.encode(name)
212
- return idna.encode(name)
213
- except idna.core.IDNAError:
214
- return None
215
-
216
- # Don't send IPv6 addresses through the IDNA encoder.
217
- if ":" in name:
218
- return name
219
-
220
- encoded_name = idna_encode(name)
221
- if encoded_name is None:
222
- return None
223
- return encoded_name.decode("utf-8")
224
-
225
-
226
- def get_subj_alt_name(peer_cert: X509) -> list[tuple[str, str]]:
227
- """
228
- Given an PyOpenSSL certificate, provides all the subject alternative names.
229
- """
230
- cert = peer_cert.to_cryptography()
231
-
232
- # We want to find the SAN extension. Ask Cryptography to locate it (it's
233
- # faster than looping in Python)
234
- try:
235
- ext = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName).value
236
- except x509.ExtensionNotFound:
237
- # No such extension, return the empty list.
238
- return []
239
- except (
240
- x509.DuplicateExtension,
241
- UnsupportedExtension,
242
- x509.UnsupportedGeneralNameType,
243
- UnicodeError,
244
- ) as e:
245
- # A problem has been found with the quality of the certificate. Assume
246
- # no SAN field is present.
247
- log.warning(
248
- "A problem was encountered with the certificate that prevented "
249
- "urllib3 from finding the SubjectAlternativeName field. This can "
250
- "affect certificate validation. The error was %s",
251
- e,
252
- )
253
- return []
254
-
255
- # We want to return dNSName and iPAddress fields. We need to cast the IPs
256
- # back to strings because the match_hostname function wants them as
257
- # strings.
258
- # Sadly the DNS names need to be idna encoded and then, on Python 3, UTF-8
259
- # decoded. This is pretty frustrating, but that's what the standard library
260
- # does with certificates, and so we need to attempt to do the same.
261
- # We also want to skip over names which cannot be idna encoded.
262
- names = [
263
- ("DNS", name)
264
- for name in map(_dnsname_to_stdlib, ext.get_values_for_type(x509.DNSName))
265
- if name is not None
266
- ]
267
- names.extend(
268
- ("IP Address", str(name)) for name in ext.get_values_for_type(x509.IPAddress)
269
- )
270
-
271
- return names
272
-
273
-
274
- class WrappedSocket:
275
- """API-compatibility wrapper for Python OpenSSL's Connection-class."""
276
-
277
- def __init__(
278
- self,
279
- connection: OpenSSL.SSL.Connection,
280
- socket: socket_cls,
281
- suppress_ragged_eofs: bool = True,
282
- ) -> None:
283
- self.connection = connection
284
- self.socket = socket
285
- self.suppress_ragged_eofs = suppress_ragged_eofs
286
- self._io_refs = 0
287
- self._closed = False
288
-
289
- def fileno(self) -> int:
290
- return self.socket.fileno()
291
-
292
- # Copy-pasted from Python 3.5 source code
293
- def _decref_socketios(self) -> None:
294
- if self._io_refs > 0:
295
- self._io_refs -= 1
296
- if self._closed:
297
- self.close()
298
-
299
- def recv(self, *args: typing.Any, **kwargs: typing.Any) -> bytes:
300
- try:
301
- data = self.connection.recv(*args, **kwargs)
302
- except OpenSSL.SSL.SysCallError as e:
303
- if self.suppress_ragged_eofs and e.args == (-1, "Unexpected EOF"):
304
- return b""
305
- else:
306
- raise OSError(e.args[0], str(e)) from e
307
- except OpenSSL.SSL.ZeroReturnError:
308
- if self.connection.get_shutdown() == OpenSSL.SSL.RECEIVED_SHUTDOWN:
309
- return b""
310
- else:
311
- raise
312
- except OpenSSL.SSL.WantReadError as e:
313
- if not util.wait_for_read(self.socket, self.socket.gettimeout()):
314
- raise timeout("The read operation timed out") from e
315
- else:
316
- return self.recv(*args, **kwargs)
317
-
318
- # TLS 1.3 post-handshake authentication
319
- except OpenSSL.SSL.Error as e:
320
- raise ssl.SSLError(f"read error: {e!r}") from e
321
- else:
322
- return data # type: ignore[no-any-return]
323
-
324
- def recv_into(self, *args: typing.Any, **kwargs: typing.Any) -> int:
325
- try:
326
- return self.connection.recv_into(*args, **kwargs) # type: ignore[no-any-return]
327
- except OpenSSL.SSL.SysCallError as e:
328
- if self.suppress_ragged_eofs and e.args == (-1, "Unexpected EOF"):
329
- return 0
330
- else:
331
- raise OSError(e.args[0], str(e)) from e
332
- except OpenSSL.SSL.ZeroReturnError:
333
- if self.connection.get_shutdown() == OpenSSL.SSL.RECEIVED_SHUTDOWN:
334
- return 0
335
- else:
336
- raise
337
- except OpenSSL.SSL.WantReadError as e:
338
- if not util.wait_for_read(self.socket, self.socket.gettimeout()):
339
- raise timeout("The read operation timed out") from e
340
- else:
341
- return self.recv_into(*args, **kwargs)
342
-
343
- # TLS 1.3 post-handshake authentication
344
- except OpenSSL.SSL.Error as e:
345
- raise ssl.SSLError(f"read error: {e!r}") from e
346
-
347
- def settimeout(self, timeout: float) -> None:
348
- return self.socket.settimeout(timeout)
349
-
350
- def _send_until_done(self, data: bytes) -> int:
351
- while True:
352
- try:
353
- return self.connection.send(data) # type: ignore[no-any-return]
354
- except OpenSSL.SSL.WantWriteError as e:
355
- if not util.wait_for_write(self.socket, self.socket.gettimeout()):
356
- raise timeout() from e
357
- continue
358
- except OpenSSL.SSL.SysCallError as e:
359
- raise OSError(e.args[0], str(e)) from e
360
-
361
- def sendall(self, data: bytes) -> None:
362
- total_sent = 0
363
- while total_sent < len(data):
364
- sent = self._send_until_done(
365
- data[total_sent : total_sent + SSL_WRITE_BLOCKSIZE]
366
- )
367
- total_sent += sent
368
-
369
- def shutdown(self) -> None:
370
- # FIXME rethrow compatible exceptions should we ever use this
371
- self.connection.shutdown()
372
-
373
- def close(self) -> None:
374
- self._closed = True
375
- if self._io_refs <= 0:
376
- self._real_close()
377
-
378
- def _real_close(self) -> None:
379
- try:
380
- return self.connection.close() # type: ignore[no-any-return]
381
- except OpenSSL.SSL.Error:
382
- return
383
-
384
- def getpeercert(
385
- self, binary_form: bool = False
386
- ) -> dict[str, list[typing.Any]] | None:
387
- x509 = self.connection.get_peer_certificate()
388
-
389
- if not x509:
390
- return x509 # type: ignore[no-any-return]
391
-
392
- if binary_form:
393
- return OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_ASN1, x509) # type: ignore[no-any-return]
394
-
395
- return {
396
- "subject": ((("commonName", x509.get_subject().CN),),), # type: ignore[dict-item]
397
- "subjectAltName": get_subj_alt_name(x509),
398
- }
399
-
400
- def version(self) -> str:
401
- return self.connection.get_protocol_version_name() # type: ignore[no-any-return]
402
-
403
- def selected_alpn_protocol(self) -> str | None:
404
- alpn_proto = self.connection.get_alpn_proto_negotiated()
405
- return alpn_proto.decode() if alpn_proto else None
406
-
407
-
408
- WrappedSocket.makefile = socket_cls.makefile # type: ignore[attr-defined]
409
-
410
-
411
- class PyOpenSSLContext:
412
- """
413
- I am a wrapper class for the PyOpenSSL ``Context`` object. I am responsible
414
- for translating the interface of the standard library ``SSLContext`` object
415
- to calls into PyOpenSSL.
416
- """
417
-
418
- def __init__(self, protocol: int) -> None:
419
- self.protocol = _openssl_versions[protocol]
420
- self._ctx = OpenSSL.SSL.Context(self.protocol)
421
- self._options = 0
422
- self.check_hostname = False
423
- self._minimum_version: int = ssl.TLSVersion.MINIMUM_SUPPORTED
424
- self._maximum_version: int = ssl.TLSVersion.MAXIMUM_SUPPORTED
425
-
426
- @property
427
- def options(self) -> int:
428
- return self._options
429
-
430
- @options.setter
431
- def options(self, value: int) -> None:
432
- self._options = value
433
- self._set_ctx_options()
434
-
435
- @property
436
- def verify_mode(self) -> int:
437
- return _openssl_to_stdlib_verify[self._ctx.get_verify_mode()]
438
-
439
- @verify_mode.setter
440
- def verify_mode(self, value: ssl.VerifyMode) -> None:
441
- self._ctx.set_verify(_stdlib_to_openssl_verify[value], _verify_callback)
442
-
443
- def set_default_verify_paths(self) -> None:
444
- self._ctx.set_default_verify_paths()
445
-
446
- def set_ciphers(self, ciphers: bytes | str) -> None:
447
- if isinstance(ciphers, str):
448
- ciphers = ciphers.encode("utf-8")
449
- self._ctx.set_cipher_list(ciphers)
450
-
451
- def load_verify_locations(
452
- self,
453
- cafile: str | None = None,
454
- capath: str | None = None,
455
- cadata: bytes | None = None,
456
- ) -> None:
457
- if cafile is not None:
458
- cafile = cafile.encode("utf-8") # type: ignore[assignment]
459
- if capath is not None:
460
- capath = capath.encode("utf-8") # type: ignore[assignment]
461
- try:
462
- self._ctx.load_verify_locations(cafile, capath)
463
- if cadata is not None:
464
- self._ctx.load_verify_locations(BytesIO(cadata))
465
- except OpenSSL.SSL.Error as e:
466
- raise ssl.SSLError(f"unable to load trusted certificates: {e!r}") from e
467
-
468
- def load_cert_chain(
469
- self,
470
- certfile: str,
471
- keyfile: str | None = None,
472
- password: str | None = None,
473
- ) -> None:
474
- try:
475
- self._ctx.use_certificate_chain_file(certfile)
476
- if password is not None:
477
- if not isinstance(password, bytes):
478
- password = password.encode("utf-8") # type: ignore[assignment]
479
- self._ctx.set_passwd_cb(lambda *_: password)
480
- self._ctx.use_privatekey_file(keyfile or certfile)
481
- except OpenSSL.SSL.Error as e:
482
- raise ssl.SSLError(f"Unable to load certificate chain: {e!r}") from e
483
-
484
- def set_alpn_protocols(self, protocols: list[bytes | str]) -> None:
485
- protocols = [util.util.to_bytes(p, "ascii") for p in protocols]
486
- return self._ctx.set_alpn_protos(protocols) # type: ignore[no-any-return]
487
-
488
- def wrap_socket(
489
- self,
490
- sock: socket_cls,
491
- server_side: bool = False,
492
- do_handshake_on_connect: bool = True,
493
- suppress_ragged_eofs: bool = True,
494
- server_hostname: bytes | str | None = None,
495
- ) -> WrappedSocket:
496
- cnx = OpenSSL.SSL.Connection(self._ctx, sock)
497
-
498
- # If server_hostname is an IP, don't use it for SNI, per RFC6066 Section 3
499
- if server_hostname and not util.ssl_.is_ipaddress(server_hostname):
500
- if isinstance(server_hostname, str):
501
- server_hostname = server_hostname.encode("utf-8")
502
- cnx.set_tlsext_host_name(server_hostname)
503
-
504
- cnx.set_connect_state()
505
-
506
- while True:
507
- try:
508
- cnx.do_handshake()
509
- except OpenSSL.SSL.WantReadError as e:
510
- if not util.wait_for_read(sock, sock.gettimeout()):
511
- raise timeout("select timed out") from e
512
- continue
513
- except OpenSSL.SSL.Error as e:
514
- raise ssl.SSLError(f"bad handshake: {e!r}") from e
515
- break
516
-
517
- return WrappedSocket(cnx, sock)
518
-
519
- def _set_ctx_options(self) -> None:
520
- self._ctx.set_options(
521
- self._options
522
- | _openssl_to_ssl_minimum_version[self._minimum_version]
523
- | _openssl_to_ssl_maximum_version[self._maximum_version]
524
- )
525
-
526
- @property
527
- def minimum_version(self) -> int:
528
- return self._minimum_version
529
-
530
- @minimum_version.setter
531
- def minimum_version(self, minimum_version: int) -> None:
532
- self._minimum_version = minimum_version
533
- self._set_ctx_options()
534
-
535
- @property
536
- def maximum_version(self) -> int:
537
- return self._maximum_version
538
-
539
- @maximum_version.setter
540
- def maximum_version(self, maximum_version: int) -> None:
541
- self._maximum_version = maximum_version
542
- self._set_ctx_options()
543
-
544
-
545
- def _verify_callback(
546
- cnx: OpenSSL.SSL.Connection,
547
- x509: X509,
548
- err_no: int,
549
- err_depth: int,
550
- return_code: int,
551
- ) -> bool:
552
- return err_no == 0