diff --git a/near-rt-ric-simulator/README.md b/near-rt-ric-simulator/README.md
index 36199d84caee78eb44c8141b655d8fd69b734b05..8268136c80efdeeed4876ee3bba5832d22cbc07b 100644
--- a/near-rt-ric-simulator/README.md
+++ b/near-rt-ric-simulator/README.md
@@ -18,13 +18,25 @@ The overall folder structure is \(relative to the location of this README file\)
 |api               |The open api yaml for each supported version |
 |src               |Python source code for each supported version |
 |test              |Basic test |
-
+|certificate       |A self-signed certificate and a key
 
 The simulator handles the requests that are defined in the A1 open API yaml file. All these requests are implemented in the a1.py file in the source folder. In addition, a number of administrative functions are also supported and implemented by the main.py in the source folder.
 
 The section below outlines the supported open api REST operations as well as the adminstrative REST operations. For the
 documentation of the common parts in the admin API, see [Common Functions](https://docs.o-ran-sc.org/projects/o-ran-sc-sim-a1-interface/en/latest/simulator-api.html#common-functions).
 
+# Ports and certificates
+
+The simulator normally opens the port 8085 for http. If a certificate and a key are provided the simulator will open port 8185 for https instead. The port 8185 is only opened if a valid certificate and key is found.
+The certificate and key shall be placed in the same dir and the dir shall be mounted to /usr/src/app/cert in the container.
+
+| Port     | Protocol |
+| -------- | ----- |
+| 8085     | http  |
+| 8185     | https |
+
+The dir certificate contains a self-signed cert. Use the script generate_cert_and_key.sh to generate a new certificate and key. The password of the certificate must be set 'test'.
+The same urls are availables on both the http port 8085 and the https port 8185. If using curl and https, the flag -k shall be given to make curl ignore checking the certificate.
 
 # Supported operations in simulator OSC 2.1.0
 
@@ -61,7 +73,7 @@ URIs for admin operations:
 |  POST, force a specific response code for an A1 operation | http://localhost:8085/forceresponse?code=<http-code> |
 |  POST, force delayed response of all A1 operations | http://localhost:8085/forcedelay?delay=<seconds> |
 |  PUT, set status and optional reason, delete and timestamp | http://localhost:8085/status?status=<status>&reason=<reason>[&deleted=<boolean>][&created\_at=<timestamp>]  |
-|  GET a counter  <br> (counter-name: 'num\_instances', 'num\_types' or 'interface') | http://localhost:8085/counter/&lt;counter-name&gt; |
+|  GET a counter  <br> (counter-name: 'num\_instances', 'num\_types', 'interface' or 'remote\_hosts') | http://localhost:8085/counter/&lt;counter-name&gt; |
 
 
 # Supported operations in simulator A1 Standard 1.1.3
@@ -91,7 +103,7 @@ URIs for admin operations:
 |  POST, force delayed response of all A1 operations | http://localhost:8085/forcedelay?delay=&lt;seconds&gt; |
 |  PUT, set status and optional reason | http://localhost:8085/status?status=&lt;status&gt;[&amp;reason=&lt;reason&gt;] |
 |  POST, send status for policy | http://localhost:8085/sendstatus?policyid=&lt;policyid&gt; |
-|  GET a counter <br> (counter-name: 'num\_instances', 'num\_types'(always 0) or 'interface') | http://localhost:8085/counter/&lt;counter-name&gt; |
+|  GET a counter <br> (counter-name: 'num\_instances', 'num\_types'(always 0), 'interface' or 'remote\_hosts') | http://localhost:8085/counter/&lt;counter-name&gt; |
 
 
 
@@ -124,13 +136,18 @@ Additionally, there are requests that are defined in main.py as an administrativ
 |  DELETE all policy types | http://localhost:8085/deletetypes |
 |  PUT a status to a policy instance with an enforceStatus parameter only | http://localhost:8085/{policyId}/{enforceStatus} |
 |  PUT a status to a policy instance with both enforceStatus and enforceReason | http://localhost:8085/{policyId}/{enforceStatus}/{enforceReason} |
-|  GET a counter  <br> (counter-name: 'num\_instances', 'num\_types' or 'interface') | http://localhost:8085/counter/{counter-name} |
+|  GET a counter  <br> (counter-name: 'num\_instances', 'num\_types', 'interface' or 'remote\_hosts') | http://localhost:8085/counter/{counter-name} |
 
 The backend server publishes live API documentation at the URL `http://localhost:8085/A1-P/v1/ui/`
 
 # Configuring the simulator
-A env variable, A1\_VERSION need to be passed to the container at start to select the desired interface version. The variable shall be set to one of the version-ids shown in the table in the first section. For example A1\_VERSIION=STD\_1.1.3.
-In docker run the full command could look like this 'docker run -it -p 8085:8085 -e A1\_VERSION=STD\_1.1.3 a1test' where the variable is set with the '-e' flag.
+An env variable, A1\_VERSION need to be passed to the container at start to select the desired interface version. The variable shall be set to one of the version-ids shown in the table in the first section. For example A1\_VERSIION=STD\_1.1.3.
+An env variable, REMOTE_HOSTS_LOGGING, can be set (any value is ok) and the the counter remote\_hosts will log the host names of all remote hosts that has accessed the A1 URIs. If host names cannot be resolved, the ip address of the remote host is logged instead. This logging is default off so must be configured to be enabled. If not configured, the counter remote\_hosts will return a fixed text indicating that host name logging is not enabled. Use this feature with caution, remote host lookup may take time in certain environments.
+The simulator can also run using the https protocol. The enable https, a valid certificate and key need to provided. There is self-signed certificate available in the certificate dir and that dir shall be mounted to the container to make it available
+
+In docker run the full command could look like this:<br> 'docker run -it -p 8085:8085 -e A1\_VERSION=STD\_1.1.3 a1test' where the variable for A1 version is set with the '-e' flag.<br>
+With logging of remote host enabled:<br> 'docker run -it -p 8085:8085 -e A1\_VERSION=STD\_1.1.3 -e REMOTE_HOSTS_LOGGING=1 a1test'<br>
+Example of running https with secure port and certificate dir mounted<br> 'docker run -it -p 8085:8085 -e A1\_VERSION=STD\_1.1.3 -e REMOTE_HOSTS_LOGGING=1 --read-only --volume /PATH_TO_CERT_DIR/certificate:/usr/src/app/cert a1test'
 
 # Updating the openapi specs
 The openapi specifications are stored in the 'api/&lt;version&gt;/'. If adding/replacing with a new file, make sure to copy the 'operationId' parameter for each operation to the new file.
@@ -144,15 +161,17 @@ There is a folder 'test/&lt;version&gt;/' for each supported simulator version.
 
 Go to the test folder of the selected version, 'test/&lt;version&gt;/.
 
-Build and start the simulator container using: ./build\_and\_start.sh
+Note that test can be performed both using the nonsecure http port and the secure https port.
+
+Build and start the simulator container using: ./build\_and\_start.sh nonsecure|secure
 This will build and start the container in interactive mode. The built container only resides in the local docker repository.
-Note, the default port is 8085 which can be easily changed in the the script above as well as in the test script.
+Note, the default port is 8085 for http and 8185 for https. When running the simulator as a container, the defualt ports can be re-mapped to any port on the localhost.
 
-In a second terminal, go to the same folder and run the basic test script, basic\_test.sh or commands.sh depending on version.
+In a second terminal, go to the same folder and run the basic test script, basic\_test.sh nonsecure|secure or commands.sh nonsecure|secure depending on version.
 This script runs a number of tests towards the simulator to make sure it works properply.
 
 Only for version 1.1.x-alpha.2
-Let the simulator run in one terminal; in another terminal, one can run the command ./commands.sh. It contains the main requests, and will eventually leave the user with a policy type STD\_QoSNudging\_0.2.0 and a policy instance pi1 with an enforceStatus set to NOT\_ENFORCED and an enforce Reason set to 300.
+Let the simulator run in one terminal; in another terminal, one can run the command ./commands.sh nonsecure|secure. It contains the main requests, and will eventually leave the user with a policy type STD\_QoSNudging\_0.2.0 and a policy instance pi1 with an enforceStatus set to NOT\_ENFORCED and an enforce Reason set to 300.
 All the response codes should be 20X, otherwise something went wrong.
 
 ## License
diff --git a/near-rt-ric-simulator/certificate/cert.crt b/near-rt-ric-simulator/certificate/cert.crt
new file mode 100644
index 0000000000000000000000000000000000000000..51e37a79a508242a2179f0607df61fb795e94a6a
--- /dev/null
+++ b/near-rt-ric-simulator/certificate/cert.crt
@@ -0,0 +1,16 @@
+-----BEGIN CERTIFICATE-----
+MIICljCCAX4CCQDVlvlNzxH9FzANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT
+RTAeFw0yMDA0MjgxOTE2MTNaFw00NzA5MTMxOTE2MTNaMA0xCzAJBgNVBAYTAlNF
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqpnXP5VmOvMPOTWaxWvm
+zfSBRvnioEFHoriGld+pW+vvvrma9UiWfxX3GaGFItxuwbwLwqwvR2LDo6wQQpbl
+SaNhg89DYD/NZvlRlLNcYOL218LjfFf4xaKVQGBHfT0Ts9JGTbTD/zcR2VS+3DUR
+lvLzbNpQ+Rdvwls7wsL1ZblR+1lry9HMGKCrtsYDSOMSyGqE40u1bOYAw1+VMrfp
+cK14u9toNPIbvk+HDP5yYnjC4FEp0ai07s3T6YDWHvp0WNIFJHCVFYzYQgS79/2b
+8zg4H7ZMQ5XjxcenU6f8Q97nN0VMk46LIutGe/7rYO0uYKrHcJz1qUu1ui96zOVC
+DQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBGvmFRHuUESpwijkekR0WFBuW6UNE5
+J7cZ9CXm7Mz06jeTAZWoCWVAZjYnpQ/MjvyzFglD9wL+A6LblIU+yNctYwtfspAq
+xDYmBKlhsKzlgZ3fyBUlfrM5BFxZR2uu1/4bUU4geEQrI2rYzif3Flj0a55EIeSa
+37fa7Acc+nNfy47mAa8Dsog6LHMs+FXGmuMS31c9lc70c9v4jCArctdDn/zKg9A7
+HCwd0+icgyDD+9U9eBhcFreBWyA1tPREWyx0qbhlw43OsVMpB6VM4exLGs/v1e0x
+/Nmmsis1o54eu2cLGjr5EYlDmdFD3Dn458r0zFkxg4CE23lRUtFz8d6F
+-----END CERTIFICATE-----
diff --git a/near-rt-ric-simulator/certificate/generate_cert_and_key.sh b/near-rt-ric-simulator/certificate/generate_cert_and_key.sh
new file mode 100755
index 0000000000000000000000000000000000000000..0f79bbf71990710f5b5b5e75b14855ca9a5e0a1a
--- /dev/null
+++ b/near-rt-ric-simulator/certificate/generate_cert_and_key.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+# This will generate a self-signed certificate with password 'test'
+openssl req -x509 -passout pass:"test" -newkey rsa:2048 -keyout key.crt -out cert.crt -days 9999
diff --git a/near-rt-ric-simulator/certificate/key.crt b/near-rt-ric-simulator/certificate/key.crt
new file mode 100644
index 0000000000000000000000000000000000000000..380e145b047c8d1d13dc89ce4f71b8b0afd0cac4
--- /dev/null
+++ b/near-rt-ric-simulator/certificate/key.crt
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIoefVgflG3OYCAggA
+MB0GCWCGSAFlAwQBKgQQEaJvnbiOIkAwGcyqi6eYCQSCBNDnK9PT/NdGvZAriJAg
+VYbqJiCxrqfrfRDAKU4Z4GWFnodzLt2+Xe6iEeOmCkCfs/oVaWx+yIMFzZKY2sq/
+jMmiihJggV+R+hIEXBsVnvqL/nqbchQ7ckhJK8ofXMcpdUdCd8CHylRPNmNNfMsu
+o3BbDjKEdCtWMmBWuMWI3DtF0U5Tu5d+nH2ZHpl7YtA7U+N5w3nWBlxoPVXmqsEH
+YE8cL0C/b+nFNs81FXKlbIPGNSv51c5YPjS0WQneci2Vj9JMPHWT6VMCaxVlv3js
+droG6AxzHH+UpB1Lx4BfVunHR79nmhzmH9mo74rWCiYZ+Kh7DnC26WHrJW/tqJX8
+AvDPIEyVsQ8JQH7omBviVs6NCwoDCwS7jX0NUTy2aWgd4feI+BLwt9SDpEIzyQHt
+YXZnwREd2ymDhS0ewvC4fjV82PJHc/yGBlNnXTh4er8hpUPjxTIuNZGaaWP7fcYP
+qqPuyfTZvTkKtzHKYsrOk6Fq7M5kMGjFBrGWK3dCNptCXM/R8gaxRqcOvEOb9G5g
+ISlC+TZy5T/EUZXJUJEK3gGMrQY4LYCxGm71Wnwe89zmC6bK/z/2XvNts867YKU+
+pODWHcxntJhwlzBRLL56dn2T0OhJEiynUMtpm45O3bHBtRkMjlQ5BhNic0Tog6fb
+757gJnbnSNFB5mCSkB09iPt8LEEamQGYUGbXE+0mPTdqwaAaKbz4Gh1yV3T9alh+
+AxJu/YaB52mmf2KdFVUuPBVzSMawYvp6hXHIgzJ6tb/GmYFI7P21RBQfVR/fKuJx
+pQMgRclNdYCAC0VCqHxSZdO0Lu7Sd/SWybCCNbfw+0tEO1fDlZwWbVQiF79AL62J
+VvaWX3pX8IF227astnyMxkCH6MB4fvu7CSZKTYgdkXekP81Ck5ZxStRcSj4jOvYj
+xuMqIvGzy16JRG1aGE1jpzunYBdDKiKKOIphH+jBK3NPk3b7wkTLxi7IkdS4MUf1
+e5E50W/Xx3wUlfyBvuc1TQy/1Moh+HvXIIG3JHU9MjfPkYwHvDITWIdXJb1vSEAE
+opi+zNt7C5A+mC1/CC2MCjHk+g+cqpLcSFmv9MXnhg8bHmuhSjaXWChD8sj/S7H4
+Kazc87gikvQguxFv+bFiVQ6+GdPcGvsrnh+UFn/kfHUM8wt2AWnrKc8OLWXbs8Ge
+0bCqXo1uy2sZEv558BGRKI35c/F4sovf0FLe8+M+UHPqOeYVaxSt9accXTHK2ajN
+IEEKuL5v0BDNTQqo0uDw0HJyKW+L55UpJQ9nNSdVjtQUnPJtbWlVg0V2Q7mnVOSF
+GRMqBtu+U9sejR03odkURjDFULntSw80M+U0LC+ceOrESLkO0AK2Yub1+IhR3OBh
+jICv3eTZbqZ27ltZrsyDTAYoRVnTvPQwSZoUJ6cQS6XgLa3QitDcj+Zqch9z7sV2
+ydkEHEbLXPIt/sQyASluKm5j1tHJVtzwezb5GO54WYwdpy3MmZ3VhXsagJc9oLHX
+MtsDGZR0hXMgzPp49leBhcieWW6fWXAZKt2oa64eI/12i2wSTjNsxPfsu45tJYXO
+GAPL0OYBKeVLi1Pfa3kCLqlMDAyC4GzTScWXad5/FEeo189JU1aGcJn7Gn7Ao805
+wuOOs1TQk+KHvAFDEGkkJEM0lg==
+-----END ENCRYPTED PRIVATE KEY-----
diff --git a/near-rt-ric-simulator/src/1.1.x-alpha.2/a1.py b/near-rt-ric-simulator/src/1.1.x-alpha.2/a1.py
index 567047ec1d1fca06e69ca3a9089d5e4aa31c9582..b326d105eb7e0844d0f504ca3791ceb40c8ee51d 100644
--- a/near-rt-ric-simulator/src/1.1.x-alpha.2/a1.py
+++ b/near-rt-ric-simulator/src/1.1.x-alpha.2/a1.py
@@ -24,9 +24,11 @@ from connexion import NoContent
 from flask import Flask, escape, request, make_response
 from jsonschema import validate
 from random import random, choice
-from var_declaration import policy_instances, policy_types, policy_status, policy_type_per_instance
+from var_declaration import policy_instances, policy_types, policy_status, policy_type_per_instance, hosts_set
+from maincommon import *
 
 def get_all_policy_identities():
+  extract_host_name(hosts_set, request)
   if len(request.args) == 0:
     return(list(policy_instances.keys()), 200)
   elif 'policyTypeId' in request.args:
@@ -39,6 +41,7 @@ def get_all_policy_identities():
     return(send_error_code(request.args))
 
 def put_policy(policyId):
+  extract_host_name(hosts_set, request)
   data = request.data.decode("utf-8")
   data = data.replace("'", "\"")
   data = json.loads(data)
@@ -100,6 +103,7 @@ def set_status(*args):
   return ps
 
 def get_policy(policyId):
+  extract_host_name(hosts_set, request)
   if len(request.args) == 0:
     if policyId in policy_instances.keys():
       res = policy_instances[policyId]
@@ -111,6 +115,7 @@ def get_policy(policyId):
     return(send_error_code(request.args))
 
 def delete_policy(policyId):
+  extract_host_name(hosts_set, request)
   if len(request.args) == 0:
     if policyId in policy_instances.keys():
       policy_instances.pop(policyId)
@@ -123,6 +128,7 @@ def delete_policy(policyId):
     return(send_error_code(request.args))
 
 def get_policy_status(policyId):
+  extract_host_name(hosts_set, request)
   if len(request.args) == 0:
     if policyId in policy_instances.keys():
       return(policy_status[policyId], 200)
@@ -132,12 +138,14 @@ def get_policy_status(policyId):
     return(send_error_code(request.args))
 
 def get_all_policytypes_identities():
+  extract_host_name(hosts_set, request)
   if len(request.args) == 0:
     return(list(policy_types.keys()), 200)
   else:
     return(send_error_code(request.args))
 
 def get_policytypes(policyTypeId):
+  extract_host_name(hosts_set, request)
   if len(request.args) == 0:
     if policyTypeId in policy_types.keys():
       return(policy_types[policyTypeId], 200)
diff --git a/near-rt-ric-simulator/src/1.1.x-alpha.2/main.py b/near-rt-ric-simulator/src/1.1.x-alpha.2/main.py
index 1ea710c8b2efc98489b61e00445abd2f96df5acc..e979bd850152a63b7a4a498109e5603e447b8740 100644
--- a/near-rt-ric-simulator/src/1.1.x-alpha.2/main.py
+++ b/near-rt-ric-simulator/src/1.1.x-alpha.2/main.py
@@ -21,15 +21,13 @@ import json
 import sys
 import os
 
-import maincommon
 
 from pathlib import Path
 from flask import Flask, escape, request, make_response
 from jsonschema import validate
-from var_declaration import policy_instances, policy_types, policy_status, policy_type_per_instance
+from var_declaration import policy_instances, policy_types, policy_status, policy_type_per_instance, hosts_set
 from maincommon import *
 
-
 check_apipath()
 
 app = connexion.App(__name__, specification_dir=apipath)
@@ -125,6 +123,9 @@ def getCounter(countername):
       p=Path(os.getcwd())
       pp=p.parts
       return str(pp[len(pp)-1]),200
+    elif (countername == "remote_hosts"):
+      hosts=",".join(hosts_set)
+      return str(hosts),200
     else:
       return "Counter name: "+countername+" not found.",404
 
@@ -134,6 +135,13 @@ if len(sys.argv) >= 2:
   if isinstance(sys.argv[1], int):
     port_number = sys.argv[1]
 
-app.add_api('a1-openapi.yaml')
-app.run(port=port_number)
+port_number_secure=8185
 
+app.add_api('a1-openapi.yaml')
+context=get_security_context()
+if (context == None):
+  print("Start on non-secure port: "+str(port_number))
+  app.run(port=port_number, host="::")
+else:
+  print("Start on secure port: "+str(port_number_secure))
+  app.run(port=port_number_secure, host="::", ssl_context=context)
\ No newline at end of file
diff --git a/near-rt-ric-simulator/src/1.1.x-alpha.2/var_declaration.py b/near-rt-ric-simulator/src/1.1.x-alpha.2/var_declaration.py
index b5a344a6e96e7761ec27fbe0cd177c4d38104a5d..f64c139c993b8ef0ea2fea380e8b9fb9be3fb1fe 100644
--- a/near-rt-ric-simulator/src/1.1.x-alpha.2/var_declaration.py
+++ b/near-rt-ric-simulator/src/1.1.x-alpha.2/var_declaration.py
@@ -19,3 +19,4 @@ policy_instances = {}
 policy_types = {}
 policy_status = {}
 policy_type_per_instance = {}
+hosts_set=set()
diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/a1.py b/near-rt-ric-simulator/src/OSC_2.1.0/a1.py
index 6db2599b9f3c175b474ebfed494459bdce140a89..eb4209cea56030816ca008f27605ef741daa2736 100644
--- a/near-rt-ric-simulator/src/OSC_2.1.0/a1.py
+++ b/near-rt-ric-simulator/src/OSC_2.1.0/a1.py
@@ -23,14 +23,16 @@ from datetime import datetime
 from connexion import NoContent
 from flask import Flask, request, Response
 from jsonschema import validate
-from var_declaration import policy_instances, policy_types, policy_status, policy_fingerprint, forced_settings
+from var_declaration import policy_instances, policy_types, policy_status, policy_fingerprint, forced_settings, hosts_set
 from utils import calcFingerprint
-from maincommon import *
+from maincommon import extract_host_name
 
 
 # API Function: Health check
 def get_healthcheck():
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -39,6 +41,8 @@ def get_healthcheck():
 # API Function: Get all policy type ids
 def get_all_policy_types():
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -47,6 +51,8 @@ def get_all_policy_types():
 # API Function: Get a policy type
 def get_policy_type(policy_type_id):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -60,6 +66,8 @@ def get_policy_type(policy_type_id):
 # API Function: Delete a policy type
 def delete_policy_type(policy_type_id):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -80,6 +88,8 @@ def delete_policy_type(policy_type_id):
 # API Function: Create a policy type
 def create_policy_type(policy_type_id):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -109,6 +119,8 @@ def create_policy_type(policy_type_id):
 # API Function: Get all policy ids for a type
 def get_all_policy_identities(policy_type_id):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -121,6 +133,8 @@ def get_all_policy_identities(policy_type_id):
 # API Function: Get a policy instance
 def get_policy_instance(policy_type_id, policy_instance_id):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -137,6 +151,8 @@ def get_policy_instance(policy_type_id, policy_instance_id):
 # API function: Delete a policy
 def delete_policy_instance(policy_type_id, policy_instance_id):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -158,6 +174,8 @@ def delete_policy_instance(policy_type_id, policy_instance_id):
 # API function: Create/update a policy
 def create_or_replace_policy_instance(policy_type_id, policy_instance_id):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -209,6 +227,8 @@ def create_or_replace_policy_instance(policy_type_id, policy_instance_id):
 # API function: Get policy status
 def get_policy_instance_status(policy_type_id, policy_instance_id):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/main.py b/near-rt-ric-simulator/src/OSC_2.1.0/main.py
index 3bc8cbe8d7adf0c31bf90032d5c08a4ce62f615e..2614ada5e7d1fb21b09a5f639ae0fabf71f9f320 100644
--- a/near-rt-ric-simulator/src/OSC_2.1.0/main.py
+++ b/near-rt-ric-simulator/src/OSC_2.1.0/main.py
@@ -24,13 +24,13 @@ import requests
 from pathlib import Path
 from flask import Flask, escape, request, Response
 from jsonschema import validate
-from var_declaration import policy_instances, policy_types, policy_status, policy_fingerprint, forced_settings
+from var_declaration import policy_instances, policy_types, policy_status, policy_fingerprint, forced_settings, hosts_set
 from maincommon import *
 
 
 check_apipath()
 
-app = connexion.App(__name__, specification_dir=apipath)
+app = connexion.FlaskApp(__name__, specification_dir=apipath)
 
 #Check alive function
 @app.route('/', methods=['GET'])
@@ -193,6 +193,9 @@ def getCounter(countername):
     p=Path(os.getcwd())
     pp=p.parts
     return Response(str(pp[len(pp)-1]),200, mimetype='text/plain')
+  elif (countername == "remote_hosts"):
+    hosts=",".join(hosts_set)
+    return str(hosts),200
   else:
     return Response("Counter name: "+countername+" not found.",404, mimetype='text/plain')
 
@@ -201,6 +204,13 @@ if len(sys.argv) >= 2:
   if isinstance(sys.argv[1], int):
     port_number = sys.argv[1]
 
-app.add_api('openapi.yaml')
-app.run(port=port_number)
+port_number_secure=8185
 
+app.add_api('openapi.yaml')
+context=get_security_context()
+if (context == None):
+  print("Start on non-secure port: "+str(port_number))
+  app.run(port=port_number, host="::")
+else:
+  print("Start on secure port: "+str(port_number_secure))
+  app.run(port=port_number_secure, host="::", ssl_context=context)
\ No newline at end of file
diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/var_declaration.py b/near-rt-ric-simulator/src/OSC_2.1.0/var_declaration.py
index f18fbca7b1941d9f1b58f7e13884d6a3349d7519..5fe04698061aae6ab743b5a3ce5a5230e88dc37b 100644
--- a/near-rt-ric-simulator/src/OSC_2.1.0/var_declaration.py
+++ b/near-rt-ric-simulator/src/OSC_2.1.0/var_declaration.py
@@ -22,3 +22,4 @@ forced_settings={}
 forced_settings['code']=None
 forced_settings['delay']=None
 policy_fingerprint={}
+hosts_set=set()
diff --git a/near-rt-ric-simulator/src/STD_1.1.3/a1.py b/near-rt-ric-simulator/src/STD_1.1.3/a1.py
index dfc81e6f58a2734feba42f07d273ca66c1653bc2..d234327a562bc180e248cc215d04d287527e16b7 100644
--- a/near-rt-ric-simulator/src/STD_1.1.3/a1.py
+++ b/near-rt-ric-simulator/src/STD_1.1.3/a1.py
@@ -24,12 +24,14 @@ import time
 
 from connexion import NoContent
 from flask import Flask, escape, request, Response, make_response
-from var_declaration import policy_instances, policy_status, callbacks, forced_settings, policy_fingerprint
+from var_declaration import policy_instances, policy_status, callbacks, forced_settings, policy_fingerprint, hosts_set
 from utils import calcFingerprint
+from maincommon import *
 
 # API Function: Get all policy ids
 def get_all_policy_identities():
 
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -38,6 +40,8 @@ def get_all_policy_identities():
 # API Function: Create or update a policy
 def put_policy(policyId):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -84,6 +88,8 @@ def put_policy(policyId):
 # API Function: Get a policy
 def get_policy(policyId):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -96,6 +102,8 @@ def get_policy(policyId):
 # API Function: Delete a policy
 def delete_policy(policyId):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
@@ -113,6 +121,8 @@ def delete_policy(policyId):
 # API Function: Get status for a policy
 def get_policy_status(policyId):
 
+  extract_host_name(hosts_set, request)
+
   if ((r := check_modified_response()) is not None):
     return r
 
diff --git a/near-rt-ric-simulator/src/STD_1.1.3/main.py b/near-rt-ric-simulator/src/STD_1.1.3/main.py
index 83aaf4a71548d78cf4abe522780bd9c88f282bbe..c46d9501b6388959a05fb47cf0b910400190db65 100644
--- a/near-rt-ric-simulator/src/STD_1.1.3/main.py
+++ b/near-rt-ric-simulator/src/STD_1.1.3/main.py
@@ -21,10 +21,11 @@ import sys
 import os
 import requests
 
+
 from pathlib import Path
 from flask import Flask, escape, request, Response
 from jsonschema import validate
-from var_declaration import policy_instances, policy_status, callbacks, forced_settings, policy_fingerprint
+from var_declaration import policy_instances, policy_status, callbacks, forced_settings, policy_fingerprint, hosts_set
 from maincommon import *
 
 
@@ -123,7 +124,7 @@ def sendstatus():
   ps=policy_status[policyid]
   cb=callbacks[policyid]
   try:
-    resp=requests.post(cb,json=json.dumps(ps))
+    resp=requests.post(cb,json=json.dumps(ps), verify=False)
   except:
     return Response('Post status failed, could not send to: '+str(cb), status=500, mimetype='text/plain')
   if (resp.status_code<199 & resp.status_code > 299):
@@ -157,6 +158,9 @@ def getCounter(countername):
     p=Path(os.getcwd())
     pp=p.parts
     return Response(str(pp[len(pp)-1]),200, mimetype='text/plain')
+  elif (countername == "remote_hosts"):
+    hosts=",".join(hosts_set)
+    return str(hosts),200
   else:
     return Response("Counter name: "+countername+" not found.",404, mimetype='text/plain')
 
@@ -165,5 +169,13 @@ if len(sys.argv) >= 2:
   if isinstance(sys.argv[1], int):
     port_number = sys.argv[1]
 
+port_number_secure=8185
+
 app.add_api('STD_A1.yaml')
-app.run(port=port_number)
+context=get_security_context()
+if (context == None):
+  print("Start on non-secure port: "+str(port_number))
+  app.run(port=port_number, host="::")
+else:
+  print("Start on secure port: "+str(port_number_secure))
+  app.run(port=port_number_secure, host="::", ssl_context=context)
diff --git a/near-rt-ric-simulator/src/STD_1.1.3/var_declaration.py b/near-rt-ric-simulator/src/STD_1.1.3/var_declaration.py
index 08fdb0c8679f419e0b38a3ca8eabc5afa447cea9..06b0031dc440d923809c810d9c10c260942d3d2e 100644
--- a/near-rt-ric-simulator/src/STD_1.1.3/var_declaration.py
+++ b/near-rt-ric-simulator/src/STD_1.1.3/var_declaration.py
@@ -21,3 +21,4 @@ forced_settings = {}
 forced_settings['code']=None
 forced_settings['delay']=None
 policy_fingerprint={}
+hosts_set=set()
diff --git a/near-rt-ric-simulator/src/common/maincommon.py b/near-rt-ric-simulator/src/common/maincommon.py
index d0b980254181b2ef4ed02c78393193ae6fe45b56..79cda3b78bf6e039e19e7c15a7277cad59712008 100644
--- a/near-rt-ric-simulator/src/common/maincommon.py
+++ b/near-rt-ric-simulator/src/common/maincommon.py
@@ -19,8 +19,13 @@ import os
 import sys
 from pathlib import Path
 from flask import Response
+import socket
+import ssl
 
+#Must exist
 apipath=os.environ['APIPATH']
+#May exist
+remote_hosts_logging=os.getenv('REMOTE_HOSTS_LOGGING')
 
 # Make sure the api path for the interface yaml file is set, otherwise exit
 def check_apipath():
@@ -37,3 +42,38 @@ def get_supported_interfaces_response():
     del arr[arr.index('start.sh')] # Remove the start script
     return Response("Current interface: " + str(pp[len(pp)-1]) + "  All supported A1 interface yamls in this container: "+str(arr), 200, mimetype='text/plain')
 
+# Remote host lookup and store host name in a set
+def extract_host_name(hosts_set, request):
+    if (remote_hosts_logging is not None):
+        host_ip=str(request.environ['REMOTE_ADDR'])
+        prefix='::ffff:'
+        if (host_ip.startswith('::ffff:')):
+            host_ip=host_ip[len(prefix):]
+        try:
+            name, alias, addresslist = socket.gethostbyaddr(host_ip)
+            hosts_set.add(name)
+        except Exception as e:
+            hosts_set.add(host_ip)
+    else:
+        hosts_set.add("logging_of_remote_host_names_not_enabled")
+
+# Check if cert is available and return a sec context, if not return 'None'
+def get_security_context():
+
+    try:
+        path="/usr/src/app/cert"
+        if (os.path.isdir(path)):
+            certpath=path+"/cert.crt"
+            keypath=path+"/key.crt"
+            if (os.path.isfile(certpath) and os.path.isfile(keypath)):
+                context = ssl.SSLContext(ssl.PROTOCOL_TLS)
+                context.load_cert_chain(certpath, keypath, password="test")
+                return context
+            else:
+                print("Cert and/or key does not exists in dir "+str(path))
+
+        else:
+            print("Path "+str(path)+" to certificate and key does not exists")
+    except Exception as e:
+        print("Problem when loading cert and key: "+str(e))
+    return None
diff --git a/near-rt-ric-simulator/test/1.1.x-alpha.2/build_and_start.sh b/near-rt-ric-simulator/test/1.1.x-alpha.2/build_and_start.sh
index bd2acdd9f54118c2c8317c9d138e75703a19e1a8..413ea89bb1b1cd95d262b91cba2f08bf47abe2b4 100755
--- a/near-rt-ric-simulator/test/1.1.x-alpha.2/build_and_start.sh
+++ b/near-rt-ric-simulator/test/1.1.x-alpha.2/build_and_start.sh
@@ -17,14 +17,31 @@
 #  ============LICENSE_END=================================================
 #
 
-#Script to build and start the container
+# Script to build and start the container
+# Args: nonsecure|secure
 
+if [ $# -ne 1 ]; then
+    echo "Usage: ./build_and_start.sh nonsecure|secure"
+    exit 1
+fi
+if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
+    echo "Usage: ./build_and_start.sh nonsecure|secure"
+    exit 1
+fi
 
+echo "Building image"
 cd ../../
 
 #Build the image
 docker build -t a1test .
 
-#Run the container in interactive mode
-docker run -it -p 8085:8085 -e A1_VERSION=1.1.x-alpha.2 a1test
+echo "Starting $1 mode"
+if [ $1 == "nonsecure" ]; then
+    #Run the container in interactive mode, unsecure port
+    docker run -it -p 8085:8085 -e A1_VERSION=1.1.x-alpha.2 -e REMOTE_HOSTS_LOGGING=1 a1test
+else
+    #Run the container in interactive mode, secure port.
+    docker run -it -p 8185:8185 -e A1_VERSION=1.1.x-alpha.2 -e REMOTE_HOSTS_LOGGING=1 --read-only --volume "$PWD/certificate:/usr/src/app/cert" a1test
+fi
+
 
diff --git a/near-rt-ric-simulator/test/1.1.x-alpha.2/commands.sh b/near-rt-ric-simulator/test/1.1.x-alpha.2/commands.sh
index 8c47afc2e37bef351907a1fbd6447074e635e58a..252789812dd827734e71a283ba7ce56d6b89d8e5 100755
--- a/near-rt-ric-simulator/test/1.1.x-alpha.2/commands.sh
+++ b/near-rt-ric-simulator/test/1.1.x-alpha.2/commands.sh
@@ -19,39 +19,61 @@
 # Different commands for the simulator.
 # By running this, nothing should return an error.
 
+# Run the build_and_start with the same arg as this script
+if [ $# -ne 1 ]; then
+    echo "Usage: ./commands.sh nonsecure|secure"
+    exit 1
+fi
+if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
+    echo "Usage: ./commands.sh nonsecure|secure"
+    exit 1
+fi
+
+if [ $1 == "nonsecure" ]; then
+    #Default http port for the simulator
+    PORT=8085
+    # Set http protocol
+    HTTPX="http"
+else
+    #Default https port for the simulator
+    PORT=8185
+    # Set https protocol
+    HTTPX="https"
+fi
+
 # Make a test
-curl -v "http://localhost:8085/"
+curl -vk "$HTTPX://localhost:$PORT/"
 
 # PUT a policy type STD_QoSNudging_0.2.0
-curl -X PUT -v "http://localhost:8085/policytypes/STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_type_STD_QoSNudging_0.2.0.json
+curl -X PUT -vk "$HTTPX://localhost:$PORT/policytypes/STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_type_STD_QoSNudging_0.2.0.json
 
 # GET policy types
-curl -v "http://localhost:8085/A1-P/v1/policytypes"
+curl -vk "$HTTPX://localhost:$PORT/A1-P/v1/policytypes"
 
 # GET policy type STD_QoSNudging_0.2.0
-curl -v "http://localhost:8085/A1-P/v1/policytypes/STD_QoSNudging_0.2.0"
+curl -vk "$HTTPX://localhost:$PORT/A1-P/v1/policytypes/STD_QoSNudging_0.2.0"
 
 # PUT a policy instance pi1
-curl -X PUT -v "http://localhost:8085/A1-P/v1/policies/pi1?policyTypeId=STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_instance_1_STD_QoSNudging_0.2.0.json
+curl -X PUT -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies/pi1?policyTypeId=STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_instance_1_STD_QoSNudging_0.2.0.json
 
 # PUT a policy instance pi2
-curl -X PUT -v "http://localhost:8085/A1-P/v1/policies/pi2?policyTypeId=STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_instance_2_STD_QoSNudging_0.2.0.json
+curl -X PUT -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies/pi2?policyTypeId=STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_instance_2_STD_QoSNudging_0.2.0.json
 
 # SET status for pi1 and pi2
-curl -X PUT "http://localhost:8085/pi1/NOT_ENFORCED/300"
-curl -X PUT "http://localhost:8085/pi2/ENFORCED"
+curl -X PUT -vk "$HTTPX://localhost:$PORT/pi1/NOT_ENFORCED/300"
+curl -X PUT -vk "$HTTPX://localhost:$PORT/pi2/ENFORCED"
 
 # GET policies
-curl -v "http://localhost:8085/A1-P/v1/policies"
+curl -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies"
 
 # DELETE policy instance pi2
-curl -X DELETE -v "http://localhost:8085/A1-P/v1/policies/pi2"
+curl -X DELETE -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies/pi2"
 
 # PUT a different policy instance pi1 (i.e. update it)
-curl -X PUT -v "http://localhost:8085/A1-P/v1/policies/pi1?policyTypeId=STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_instance_1_bis_STD_QoSNudging_0.2.0.json
+curl -X PUT -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies/pi1?policyTypeId=STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_instance_1_bis_STD_QoSNudging_0.2.0.json
 
 # GET policy instance pi1
-curl -v "http://localhost:8085/A1-P/v1/policies/pi1"
+curl -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies/pi1"
 
 # GET policy status for pi1
-curl -v "http://localhost:8085/A1-P/v1/policystatus/pi1"
+curl -vk "$HTTPX://localhost:$PORT/A1-P/v1/policystatus/pi1"
diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh b/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh
index 5cc12140af07bbdaea90e45954828b40b337a8c7..8d205f0992737e4ac800406dbc8f9e4d79f099c8 100755
--- a/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh
+++ b/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh
@@ -17,8 +17,28 @@
 #  ============LICENSE_END=================================================
 #
 
-#Default port for the simulator
-PORT=8085
+# Script for basic test of the simulator.
+# Run the build_and_start with the same arg as this script
+if [ $# -ne 1 ]; then
+    echo "Usage: ./basic_test.sh nonsecure|secure"
+    exit 1
+fi
+if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
+    echo "Usage: ./basic_test.sh nonsecure|secure"
+    exit 1
+fi
+
+if [ $1 == "nonsecure" ]; then
+    #Default http port for the simulator
+    PORT=8085
+    # Set http protocol
+    HTTPX="http"
+else
+    #Default https port for the simulator
+    PORT=8185
+    # Set https protocol
+    HTTPX="https"
+fi
 
 . ../common/test_common.sh
 
@@ -230,6 +250,10 @@ echo "=== Get counter: interface ==="
 RESULT="OSC_2.1.0"
 do_curl GET '/counter/interface' 200
 
+echo "=== Get counter: remote hosts ==="
+RESULT="*"
+do_curl GET '/counter/remote_hosts' 200
+
 echo "=== DELETE policy pi1 ==="
 RESULT=""
 do_curl DELETE /a1-p/policytypes/1/policies/pi1 202
diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh b/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh
index afa56090947501c787e9632b60b86db9a027cc77..89907d6093ab1e6f279e65af39fa74dcfdc04d06 100755
--- a/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh
+++ b/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh
@@ -17,14 +17,30 @@
 #  ============LICENSE_END=================================================
 #
 
-#Script to build and start the container
+# Script to build and start the container
+# Args: nonsecure|secure
 
+if [ $# -ne 1 ]; then
+    echo "Usage: ./build_and_start.sh nonsecure|secure"
+    exit 1
+fi
+if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
+    echo "Usage: ./build_and_start.sh nonsecure|secure"
+    exit 1
+fi
 
+echo "Building image"
 cd ../../
 
 #Build the image
 docker build -t a1test .
 
-#Run the container in interactive mode
-docker run -it -p 8085:8085 -e A1_VERSION=OSC_2.1.0 a1test
+echo "Starting $1 mode"
+if [ $1 == "nonsecure" ]; then
+    #Run the container in interactive mode, unsecure port
+    docker run -it -p 8085:8085 -e A1_VERSION=OSC_2.1.0 -e REMOTE_HOSTS_LOGGING=1 a1test
+else
+    #Run the container in interactive mode, secure port.
+    docker run -it -p 8185:8185 -e A1_VERSION=OSC_2.1.0 -e REMOTE_HOSTS_LOGGING=1 --read-only --volume "$PWD/certificate:/usr/src/app/cert" a1test
+fi
 
diff --git a/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh b/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh
index 9274eaa4956ba21dd91d1d888379463417590196..7dbe131dc31f72bfa5b9a2990935e8b155f011a5 100755
--- a/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh
+++ b/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh
@@ -17,8 +17,28 @@
 #  ============LICENSE_END=================================================
 #
 
-#Default port for the simulator
-PORT=8085
+# Script for basic test of the simulator.
+# Run the build_and_start with the same arg as this script
+if [ $# -ne 1 ]; then
+    echo "Usage: ./basic_test.sh nonsecure|secure"
+    exit 1
+fi
+if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
+    echo "Usage: ./basic_test.sh nonsecure|secure"
+    exit 1
+fi
+
+if [ $1 == "nonsecure" ]; then
+    #Default http port for the simulator
+    PORT=8085
+    # Set http protocol
+    HTTPX="http"
+else
+    #Default https port for the simulator
+    PORT=8185
+    # Set https protocol
+    HTTPX="https"
+fi
 
 . ../common/test_common.sh
 
@@ -77,7 +97,7 @@ do_curl PUT /A1-P/v1/policies/pi2 201 jsonfiles/pi2.json
 
 echo "=== API: Update policy instance pi2 ==="
 RESULT="json:{\"scope\": {\"ueId\": \"ue2\", \"groupId\": \"group2\", \"sliceId\": \"slice2\", \"qosId\": \"qos2\", \"cellId\": \"cell2\"}, \"statement\": {\"priorityLevel\": 10}}"
-do_curl PUT '/A1-P/v1/policies/pi2?notificationDestination=http://localhost:8085/statustest' 200 jsonfiles/pi2.json
+do_curl PUT '/A1-P/v1/policies/pi2?notificationDestination='$HTTPX'://localhost:'$PORT'/statustest' 200 jsonfiles/pi2.json
 
 echo "=== API: Get policy instances, shall contain pi1 and pi2=="
 RESULT="json:[ \"pi1\", \"pi2\" ]"
@@ -143,6 +163,10 @@ echo "=== Get counter: interface ==="
 RESULT="STD_1.1.3"
 do_curl GET /counter/interface 200
 
+echo "=== Get counter: remote hosts ==="
+RESULT="*"
+do_curl GET '/counter/remote_hosts' 200
+
 echo "********************"
 echo "*** All tests ok ***"
 echo "********************"
diff --git a/near-rt-ric-simulator/test/STD_1.1.3/build_and_start.sh b/near-rt-ric-simulator/test/STD_1.1.3/build_and_start.sh
index dd1ac8a7df41743c2c5d90592d1d3dd7e22c4db5..1dcacc4b6c06e51eaf8c480aa6b730d0f9594c83 100755
--- a/near-rt-ric-simulator/test/STD_1.1.3/build_and_start.sh
+++ b/near-rt-ric-simulator/test/STD_1.1.3/build_and_start.sh
@@ -17,13 +17,29 @@
 #  ============LICENSE_END=================================================
 #
 
-#Script to build and start the container
+# Script to build and start the container
+# Args: nonsecure|secure
 
+if [ $# -ne 1 ]; then
+    echo "Usage: ./build_and_start.sh nonsecure|secure"
+    exit 1
+fi
+if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
+    echo "Usage: ./build_and_start.sh nonsecure|secure"
+    exit 1
+fi
 
+echo "Building image"
 cd ../../
 
 #Build the image
 docker build -t a1test .
 
-#Run the container in interactive mode
-docker run -it -p 8085:8085 -e A1_VERSION=STD_1.1.3 a1test
\ No newline at end of file
+echo "Starting $1 mode"
+if [ $1 == "nonsecure" ]; then
+    #Run the container in interactive mode, unsecure port
+    docker run -it -p 8085:8085 -e A1_VERSION=STD_1.1.3 -e REMOTE_HOSTS_LOGGING=1 a1test
+else
+    #Run the container in interactive mode, secure port.
+    docker run -it -p 8185:8185 -e A1_VERSION=STD_1.1.3 -e REMOTE_HOSTS_LOGGING=1 --read-only --volume "$PWD/certificate:/usr/src/app/cert" a1test
+fi
\ No newline at end of file
diff --git a/near-rt-ric-simulator/test/common/compare_json.py b/near-rt-ric-simulator/test/common/compare_json.py
index 53bddb1731596e1e65e819a2e1019d2dac61b2d9..5766622fdeaa98c5163298e1b1f43ce30fd160d7 100644
--- a/near-rt-ric-simulator/test/common/compare_json.py
+++ b/near-rt-ric-simulator/test/common/compare_json.py
@@ -16,51 +16,98 @@
 #  ============LICENSE_END=================================================
 #
 
-# Deep compare of two json obects
-# If a parameter value in the target json is set to '????' then the result json value is not checked for that parameter
-# Any included json array will be sorted before comparison
+# This script compare two jsons for eqaulity, taken into account that the parameter values
+# marked with '????' are not checked (only the parameter name need to exist)
+# Example of target json with '????'
+# [
+#   {
+#     "callbackUrl": "????",
+#     "keepAliveIntervalSeconds": "????",
+#     "serviceName": "serv2",
+#     "timeSinceLastActivitySeconds": "????"
+#   },
+#   {
+#     "callbackUrl": "????",
+#     "keepAliveIntervalSeconds": "????",
+#     "serviceName": "serv1",
+#     "timeSinceLastActivitySeconds": "????"
+#   }
+#]
 
-import sys
+
+import os
 import json
+import sys
+
+# # Helper function to compare two json list.
+# # Returns true for equal, false for not equal
+def compare_json_list(list1, list2):
+    if (list1.__len__() != list2.__len__()):
+        return False
 
-def compare_json(jsonTarget,jsonResult):
+    for l in list1:
+        found = False
+        for m in list2:
+            res = compare_json(l, m)
+            if (res):
+                found = True
+                break
 
+        if (not found):
+            return False
 
-    if isinstance(jsonTarget, dict):
-        if (len(jsonTarget) != len(jsonResult)):
-            return 1
-        for key in jsonTarget.keys():
-            if (jsonResult.get(key) is None):
-                return 1
-            res=compare_json(jsonTarget.get(key), jsonResult.get(key))
-            if (res != 0):
-                return 1
-    elif isinstance(jsonTarget, list):
-        if (len(jsonTarget) != len(jsonResult)):
-            return 1
-        jsonTarget.sort()
-        jsonResult.sort()
-        for i in range(len(jsonTarget)):
-            res=compare_json(jsonTarget[i], jsonResult[i])
-            if (res != 0):
-                return 1
+    return True
+
+# Deep compare of two json obects
+# If a parameter value in the target json is set to '????' then the result json value is not checked for the that parameter
+# Return true for equal json, false for not equal json
+def compare_json(obj1, obj2):
+    if isinstance(obj1, list):
+        if (not isinstance(obj2, list)):
+            return False
+        return compare_json_list(obj1, obj2)
+    elif (isinstance(obj1, dict)):
+        if (not isinstance(obj2, dict)):
+            return False
+        exp = set(obj2.keys()) == set(obj1.keys())
+        if (not exp):
+            return False
+        for k in obj1.keys():
+            val1 = obj1.get(k)
+            val2 = obj2.get(k)
+            if isinstance(val1, list):
+                if (not compare_json_list(val1, val2)):
+                    return False
+            elif isinstance(val1, dict):
+                if (not compare_json(val1, val2)):
+                    return False
+            else:
+                #Do not check parameter values marked with '????'
+                if ((val1 != "????") and (val2 != val1)) and ((val2 != "????") and (val2 != val1)):
+                    return False
     else:
-        if (jsonTarget != "????") and (jsonTarget != jsonResult):
-            return 1
-    return 0
+        return obj1 == obj2
+
+    return True
 
 
 try:
+    #Read the input file and compare the two json (target->result)
     jsonTarget = json.loads(sys.argv[1])
     jsonResult = json.loads(sys.argv[2])
+    res1=compare_json(jsonTarget, jsonResult)
 
-    print(compare_json(jsonTarget,jsonResult))
+    #Read the json again (in case the previous calls has re-arranged the jsons)
+    jsonTarget = json.loads(sys.argv[1])
+    jsonResult = json.loads(sys.argv[2])
+    #Compare the opposite order (result->target) to catch special duplicate json key cases
+    res2=compare_json(jsonResult, jsonTarget)
+
+    if (res1 and res2):
+        print (0)
+    else:
+        print (1)
 
 except Exception as e:
     print (1)
-sys.exit()
-
-
-
-
-
+sys.exit()
\ No newline at end of file
diff --git a/near-rt-ric-simulator/test/common/test_common.sh b/near-rt-ric-simulator/test/common/test_common.sh
index b142ce8b1c5f5bd13173588710465f79ef8ecab6..6c669c1110e928586ff19afd344f78bcb351480f 100755
--- a/near-rt-ric-simulator/test/common/test_common.sh
+++ b/near-rt-ric-simulator/test/common/test_common.sh
@@ -19,6 +19,9 @@
 
 # Function to execute curl and compare + print result
 
+# Note: Env var PORT must be set to the intended port number
+# Notre Env var HTTPX must be set to either 'http' or 'https'
+
 #args: <http-operation> <url> <response-code> [file]
 #Expects the env $RESULT to contain the expected RESULT.
 #If json, the RESULT shall begin with 'json:'.
@@ -29,7 +32,7 @@ do_curl() {
         echo "Exiting test script....."
         exit 1
     fi
-    curlstr="curl -X "$1" -sw %{http_code} localhost:"${PORT}${2}" -H accept:*/*"
+    curlstr="curl -X "$1" -skw %{http_code} $HTTPX://localhost:"${PORT}${2}" -H accept:*/*"
     if [ $# -gt 3 ]; then
         curlstr=$curlstr" -H Content-Type:application/json --data-binary @"$4
     fi