Skip to content

Commit

Permalink
new: usr: added option for disabling SSL checks (refs #83)
Browse files Browse the repository at this point in the history
Added the `insecure` configuration option for disabling HTTPS SSL
certificate validation.
Set it to `True` when the PlantUML server uses self-signed certificates.
  • Loading branch information
mikitex70 committed Jan 29, 2023
1 parent 6f36347 commit 79d5f7b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -181,13 +181,15 @@ In either cases you need to specify the URL of the server in a configuration fil
plantuml_markdown:
server: http://www.plantuml.com/plantuml # PlantUML server, for remote rendering
# other global options
insecure: False # set to True if the server uses self-signed certificates
cachedir: /tmp # set a non-empty value to enable caching
base_dir: . # where to search for diagrams to include
format: png # default diagram image format
classes: class1,class2 # default diagram classes
encoding: utf-8 # character encoding for external files (default utf-8)
title: UML diagram # default title (tooltip) for diagram images
alt: UML diagram image # default `alt` attribute for diagram images
image_maps: True # generate image maps when the format is png and there are hyperlinks
priority: 30 # plugin priority; the higher, the sooner will be applied (default 30)
http_method: GET # GET or POST - note that plantuml.com only supports GET (default GET)
fallback_to_get: True # When using POST, should GET be used as fallback (POST will fail if @startuml/@enduml tags not used) (default True)
Expand Down Expand Up @@ -247,8 +249,10 @@ The plugin has several configuration option:
* `remove_inline_svg_size`: When `format` is `svg_inline`, remove the `width` and `height` attributes of the generated
SVG. Defaults to True
* `http_method`: Http Method for server - `GET` or `POST`. "Defaults to `GET`
* `image_maps`: generate image maps if format is `png` and the diagram has hyperlinks; `true`, `on`, `yes` or `1`
* `image_maps`: generate image maps if format is `png` and the diagram has hyperlinks; `true`, `on`, `yes` or `1`
activates image maps, everything else disables it. Defaults to `true`
* `insecure`: if `True` do not validate SSL certificate of the PlantUML server; set to `True` when using a custom
PlantUML installation with self-signed certificates. Defaults to `False`
* `kroki_server`: Kroki server url, as alternative to `server` for remote rendering (image maps mus be disabled
manually). Defaults to `''`, use PlantUML server if defined
* `priority`: extension priority. Higher values means the extension is applied sooner than others. Defaults to `30`
Expand Down
6 changes: 4 additions & 2 deletions plantuml_markdown.py
Expand Up @@ -452,7 +452,8 @@ def _render_remote_uml_image(
# image_url for POST attempt first
image_url = "%s/%s/" % (self._server, img_format)
# download manually the image to be able to continue in case of errors
r = session.post(image_url, data=temp_file, headers={"Content-Type": 'text/plain; charset=utf-8'})
r = session.post(image_url, data=temp_file, headers={"Content-Type": 'text/plain; charset=utf-8'},
verify=not self.config['insecure'])

if r.ok:
return r.content, None
Expand All @@ -468,7 +469,7 @@ def _render_remote_uml_image(
else:
image_url = self._server+"/"+img_format+"/"+self._deflate_and_encode(temp_file)

return self._handle_response(session.get(image_url))
return self._handle_response(session.get(image_url, verify=not self.config['insecure']))

def _handle_response(self, resp: Response) -> Tuple[Optional[bytes], Optional[str]]:
if not resp.ok and self._kroki_server:
Expand Down Expand Up @@ -607,6 +608,7 @@ def __init__(self, **kwargs):
'server_include_whitelist': [[r'^[Cc]4.*$'],
"List of regular expressions defining which include files are supported by "
"the server. Defaults to [r'^c4.*$']"],
'insecure': ["False", "Disable SSL certificates verification; set to True if you server uses self-signed certificates. Defaults to False"],
'cachedir': ["", "Directory for caching of diagrams. Defaults to '', no caching"],
'image_maps': ["true", "Enable generation of PNG image maps, allowing to use hyperlinks with PNG images."
"Defaults to true"],
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -15,7 +15,7 @@

setuptools.setup(
name="plantuml-markdown",
version="3.8.0",
version="3.8.1",
author="Michele Tessaro",
author_email="michele.tessaro@email.it",
description="A PlantUML plugin for Markdown",
Expand Down

0 comments on commit 79d5f7b

Please sign in to comment.