Skip to content

Commit

Permalink
fix SSL error
Browse files Browse the repository at this point in the history
  • Loading branch information
Samweli authored and nyalldawson committed Jun 5, 2020
1 parent 33cbf25 commit 94106dc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
17 changes: 15 additions & 2 deletions python/plugins/MetaSearch/dialogs/maindialog.py
Expand Up @@ -51,6 +51,7 @@

from owslib.fes import BBox, PropertyIsLike
from owslib.ows import ExceptionReport
from owslib.util import Authentication

from MetaSearch import link_types
from MetaSearch.dialogs.manageconnectionsdialog import ManageConnectionsDialog
Expand Down Expand Up @@ -96,6 +97,7 @@ def __init__(self, iface):
self.startfrom = 0
self.maxrecords = 10
self.timeout = 10
self.disable_ssl = False
self.constraints = []

# Servers tab
Expand Down Expand Up @@ -447,6 +449,9 @@ def search(self):
# set timeout
self.timeout = self.spnTimeout.value()

# ssl mode
self.disable_ssl = self.disableSSL.isChecked()

# bbox
# CRS is WGS84 with axis order longitude, latitude
# defined by 'urn:ogc:def:crs:OGC:1.3:CRS84'
Expand Down Expand Up @@ -828,9 +833,13 @@ def show_metadata(self):

try:
with OverrideCursor(Qt.WaitCursor):
auth = None
if self.disable_ssl:
auth = Authentication(verify=False)
cat = CatalogueServiceWeb(self.catalog_url, timeout=self.timeout, # spellok
username=self.catalog_username,
password=self.catalog_password)
password=self.catalog_password,
auth=auth)
cat.getrecordbyid(
[self.catalog.records[identifier].identifier])
except ExceptionReport as err:
Expand Down Expand Up @@ -907,11 +916,15 @@ def _get_csw(self):

# connect to the server
with OverrideCursor(Qt.WaitCursor):
auth = None
if self.disable_ssl:
auth = Authentication(verify=False)
try:
self.catalog = CatalogueServiceWeb(self.catalog_url, # spellok
timeout=self.timeout,
username=self.catalog_username,
password=self.catalog_password)
password=self.catalog_password,
auth=auth)
return True
except ExceptionReport as err:
msg = self.tr('Error connecting to service: {0}').format(err)
Expand Down
31 changes: 26 additions & 5 deletions python/plugins/MetaSearch/ui/maindialog.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>656</width>
<width>658</width>
<height>550</height>
</rect>
</property>
Expand Down Expand Up @@ -488,23 +488,44 @@
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Server Timeout</string>
<string>Server</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="2">
<widget class="QSpinBox" name="spnTimeout">
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Disable SSL</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="disableSSL">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_9">
<property name="text">
<string>seconds</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Timeout</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 94106dc

Please sign in to comment.