# note: we will store the certificate and private key in STEP 3

print("")
print(
    "==========================================================================================="
)
print("STEP 2: Create a Client instance")
print(
    "==========================================================================================="
)
print("")

# define the clientSettings
clientSettings = ClientSettings()
clientSettings.applicationName = "MyClient"
clientSettings.applicationUri = info.uri  # Certificate info URI and application URI must be the same !!!
#clientSettings.logToStdOutLevel = pyuaf.util.loglevels.Debug # uncomment if needed
clientSettings.discoveryUrls.append(DISCOVERY_URL)

# We configure the PKI folder structure (set the PKI_FOLDER to 'PKI' and you get the defaults).
# Note that paths must ALWAYS be specified using '/', also on Windows!
# You cannot use os.path.join or similar, since these will introduce platform-dependent separators!
clientSettings.clientCertificate = PKI_FOLDER + '/client/certs/client.der'
clientSettings.clientPrivateKey = PKI_FOLDER + '/client/private/client.pem'
clientSettings.certificateTrustListLocation = PKI_FOLDER + '/trusted/certs/'
clientSettings.certificateRevocationListLocation = PKI_FOLDER + '/trusted/crl/'
clientSettings.issuersCertificatesLocation = PKI_FOLDER + '/issuers/certs/'
clientSettings.issuersRevocationListLocation = PKI_FOLDER + '/issuers/crl/'

# make sure the above directories are created
clientSettings.createSecurityLocations()
certificate = PkiCertificate(info, identity, subjectPublicKey, identity, issuerPrivateKey)

# note: we will store the certificate and private key in STEP 3

print("")
print("===========================================================================================")
print("STEP 2: Create a Client instance")
print("===========================================================================================")
print("")


# define the clientSettings
clientSettings = ClientSettings()
clientSettings.applicationName = "MyClient"
clientSettings.applicationUri = info.uri  # Certificate info URI and application URI must be the same !!!
# clientSettings.logToStdOutLevel = pyuaf.util.loglevels.Debug # uncomment if needed
clientSettings.discoveryUrls.append(DISCOVERY_URL)

# We configure the PKI folder structure (set the PKI_FOLDER to 'PKI' and you get the defaults).
# Note that paths must ALWAYS be specified using '/', also on Windows!
# You cannot use os.path.join or similar, since these will introduce platform-dependent separators!
clientSettings.clientCertificate = PKI_FOLDER + "/client/certs/client.der"
clientSettings.clientPrivateKey = PKI_FOLDER + "/client/private/client.pem"
clientSettings.certificateTrustListLocation = PKI_FOLDER + "/trusted/certs/"
clientSettings.certificateRevocationListLocation = PKI_FOLDER + "/trusted/crl/"
clientSettings.issuersCertificatesLocation = PKI_FOLDER + "/issuers/certs/"
clientSettings.issuersRevocationListLocation = PKI_FOLDER + "/issuers/crl/"

# make sure the above directories are created
clientSettings.createSecurityLocations()