IPWorks EDI 2020 Python Edition

Questions / Feedback?

AS2Sender Class

Properties   Methods   Events   Configuration Settings   Errors  

The AS2Sender class implements an AS2 / EDI-INT client.

Syntax

class ipworksedi.AS2Sender

Remarks

The AS2Sender component may be used to send EDI or other messages over HTTP/S, using the AS2 protocol. It may also be used to verify synchronous or asynchronous server responses.

A typical AS2 transaction is as follows:

(1) The sender sends an EDI document to the receiver using HTTP or HTTPS. Typically the document will be signed and encrypted (particularly if SSL is not used). A signed receipt will also be requested.

(2) The receiver decrypts the message and verifies the signature.

(3) The receiver sends a signed receipt back to the client. The signature is over the hash of an MDN, which contains a hash of the received message.

When sending an EDI message, the client should specify, at a minimum, as2_from and as2_to, url, and edi_data. The post method should then be invoked.

To secure the EDI transmission, the message may be signed and/or encrypted by setting the appropriate certificates. By default, the class will apply message security if the appropriate certificates are specified. To sign the data, set signing_cert. To encrypt, set recipient_certs. If the recipient uses different certificates for signing and encryption it will also be necessary to set receipt_signer_cert.

SSL will also be used if the scheme in url is "https". If your trading partner is using a self-signed certificate, it will be necessary to set ssl_accept_server_cert or trap the on_ssl_server_authentication event to accept the certificate.

The message may also be compressed by setting compression_format.

To request a receipt, or Message Disposition Notification (MDN), simply set the mdn_to property. The mdn_options property may be used to customize the request. By default, the class will request a signed MDN over an SHA1 hash.

The class supports both synchronous and asynchronous MDN receipt delivery. By default, the class requests synchronous MDN receipt delivery, and the MDN will be returned in the HTTP reply. To request asynchronous MDN delivery, set the mdn_delivery_option to the URL where MDN's are to be delivered.

The HTTP reply will automatically be processed by the class. If an MDN was requested, post will validate the MDN and (if signed) establish non-repudiation of receipt. Any errors or warnings will cause the class to throw an exception.

In either case, after the EDI transaction is processed successfully, the mdn_receipt will be populated with the appropriate values.

Validating Asynchronous MDNs

The class may also be used to process and verify asynchronous MDNs. To do this, you should invoke read_async_receipt. This will read the receipt from the current HTTP context (or from mdn_receipt, if set manually), and allow you to determine your trading partner's identity and the message ID. You should then set receipt_signer_cert and original_content_mic, and finally invoke verify_receipt.

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

as2_fromThe AS2 Identifier of the sending system.
as2_toThe AS2 Identifier of the receiving system.
as2_versionThe version of AS2 being used.
async_mdn_info_dirPath to a directory to store data used in verifying AsyncMDNs.
attachment_countThe number of records in the Attachment arrays.
attachment_content_typeThe MIME content-type of this ediattachment .
attachment_dataThis property contains the attachment data.
attachment_filenameThe file name of the attachment.
attachment_headersThe class fills out Headers each time any of the other properties for that ediattachment are changed.
attachment_nameName is the final name to be associated with the contents of either the Data or Filename properties.
cem_countThe number of records in the CEM arrays.
cem_acceptedWhether the CEM request is accepted.
cem_cert_idA user defined identifier for the certificate.
cem_cert_issuerThis property holds the issuer of the certificate.
cem_cert_serial_numberThis property holds the serial number of the certificate.
cem_cert_storeThe name of the certificate store for the certificate.
cem_cert_store_passwordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
cem_cert_store_typeThe type of certificate store for this certificate.
cem_cert_subjectThe subject of the certificate.
cem_cert_usageThis property defines which usages are applicable to the certificate.
cem_rejection_reasonIf Accepted is False this property specifies the reason a request was rejected.
cem_respond_by_dateThis property specifies the date by which the other party should respond.
cem_response_urlThis property defines the URL to which the response should be sent.
compression_formatThe compression format (if any) to use.
cookie_countThe number of records in the Cookie arrays.
cookie_domainThe domain of a received cookie.
cookie_expirationThis property contains an expiration time for the cookie (if provided by the server).
cookie_nameThe name of the cookie.
cookie_pathThis property contains a path name to limit the cookie to (if provided by the server).
cookie_secureThis property contains the security flag of the received cookie.
cookie_valueThis property contains the value of the cookie.
edi_dataThis property contains the EDI payload of the transmission.
edi_typeThe Content-Type of the EDI message.
edi_filenameIn a sender, if Filename is specified, the file specified will be used for the EDI payload of the transmission.
edi_nameName is the final name to be associated with the contents of either the Data or FileName properties.
encryption_algorithmThe algorithm used to encrypt the EDI data.
etagThe Etag of the file being sent.
firewall_auto_detectThis property tells the class whether or not to automatically detect and use firewall system settings, if available.
firewall_typeThis property determines the type of firewall to connect through.
firewall_hostThis property contains the name or IP address of firewall (optional).
firewall_passwordThis property contains a password if authentication is to be used when connecting through the firewall.
firewall_portThis property contains the TCP port for the firewall Host .
firewall_userThis property contains a user name if authentication is to be used connecting through a firewall.
from_The email address of the HTTP agent (optional).
local_hostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
log_directoryThe path to a directory for logging.
log_fileThe log file written.
mdn_delivery_optionA URL indicating how the receipt is to be delivered.
mdn_optionsUsed to indicate the options requested for the MDN receipt.
mdn_receipt_contentThis contains the entire content of the MDN Receipt.
mdn_receipt_header_countThe number of headers in the MDN.
mdn_receipt_header_fieldThe property name of the MDN header currently selected by HeaderIndex .
mdn_receipt_header_indexWhich MDN header is currently selected to populate HeaderField and HeaderValue .
mdn_receipt_headersHeaders contains all of the headers of the AS2 MDN Receipt as a single string.
mdn_receipt_header_valueThe value of the MDN header currently selected by HeaderIndex .
mdn_receipt_mdnMDN will contain the entire machine readable text of the Message Disposition Notification in the receipt.
mdn_receipt_messageThe human-readable portion of the MDN receipt.
mdn_receipt_mic_valueThe Message Integrity Check(s) (one-way hash) of the original EDI message.
mdn_receipt_signing_protocolThis property contains the MIME type of the signature used, if any (i.
mdn_toUsed to indicate that a message disposition notification is requested.
message_idThe Id of the message.
original_content_micThe Message Integrity Check(s) (one-way hash) of the outgoing message.
proxy_auth_schemeThis property is used to tell the class which type of authorization to perform when connecting to the proxy.
proxy_auto_detectThis property tells the class whether or not to automatically detect and use proxy system settings, if available.
proxy_passwordThis property contains a password if authentication is to be used for the proxy.
proxy_portThis property contains the TCP port for the proxy Server (default 80).
proxy_serverIf a proxy Server is given, then the HTTP request is sent to the proxy instead of the server otherwise specified.
proxy_sslThis property determines when to use SSL for the connection to the proxy.
proxy_userThis property contains a user name, if authentication is to be used for the proxy.
receipt_signer_cert_encodedThe certificate (PEM/base64 encoded).
receipt_signer_cert_storeThe name of the certificate store for the client certificate.
receipt_signer_cert_store_passwordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
receipt_signer_cert_store_typeThe type of certificate store for this certificate.
receipt_signer_cert_subjectThe subject of the certificate used for client authentication.
recipient_cert_countThe number of records in the RecipientCert arrays.
recipient_cert_encodedThe certificate (PEM/base64 encoded).
recipient_cert_storeThe name of the certificate store for the client certificate.
recipient_cert_store_passwordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
recipient_cert_store_typeThe type of certificate store for this certificate.
recipient_cert_subjectThe subject of the certificate used for client authentication.
restart_directoryThe directory to log cached files when using AS2 restart functionality.
rollover_signing_cert_encodedThe certificate (PEM/base64 encoded).
rollover_signing_cert_storeThe name of the certificate store for the client certificate.
rollover_signing_cert_store_passwordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
rollover_signing_cert_store_typeThe type of certificate store for this certificate.
rollover_signing_cert_subjectThe subject of the certificate used for client authentication.
signature_algorithmSignature algorithm to be used in outgoing messages.
signing_cert_encodedThe certificate (PEM/base64 encoded).
signing_cert_storeThe name of the certificate store for the client certificate.
signing_cert_store_passwordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
signing_cert_store_typeThe type of certificate store for this certificate.
signing_cert_subjectThe subject of the certificate used for client authentication.
ssl_accept_server_cert_encodedThe certificate (PEM/base64 encoded).
ssl_cert_encodedThe certificate (PEM/base64 encoded).
ssl_cert_storeThe name of the certificate store for the client certificate.
ssl_cert_store_passwordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
ssl_cert_store_typeThe type of certificate store for this certificate.
ssl_cert_subjectThe subject of the certificate used for client authentication.
ssl_server_cert_encodedThe certificate (PEM/base64 encoded).
subjectThe subject of the message.
timeoutA timeout for the class.
urlThe URL to which the request is made.
use_oaepWhether to use Optimal Asymmetric Encryption Padding (OAEP).
use_pssWhether to use RSA-PSS during signing and verification.
user_agentInformation about the user agent.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

configSets or retrieves a configuration setting.
do_eventsProcesses events from the internal message queue.
interruptInterrupt the current method.
postPost data to the AS2 server, and check the receipt.
read_async_receiptReads an asynchronous MDN receipt from the current HTTP session.
resetResets the state of the control.
restartRestart sending of the file specified by the Etag property.
send_cem_requestSends a Certificate Exchange Messaging (CEM) request.
send_cem_responseSends a Certificate Exchange Messaging (CEM) response.
set_request_headerAllows the user to set or add arbitrary HTTP request headers.
set_tp_infoA convenient way to set AS2 communication parameters using XML strings.
verify_receiptVerifies an asynchronous MDN receipt.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

on_connectedFired immediately after a connection completes (or fails).
on_disconnectedFired when a connection is closed.
on_end_transferFired when a document finishes transferring.
on_errorInformation about errors during data delivery.
on_headerFired every time a header line comes in.
on_logFired with log information while processing a message.
on_set_cookieFired for every cookie set by the server.
on_ssl_server_authenticationFired after the server presents its certificate to the client.
on_ssl_statusShows the progress of the secure connection.
on_start_transferFired when a document starts transferring (after the headers).
on_transferFired while a document transfers (delivers document).

Configuration Settings


The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.

AllowMDNWarningsWhether to fail on MDN warnings.
AuthorizationThe Authorization string to be sent to the server.
AuthSchemeThe authorization scheme to be used when server authorization is to be performed.
EncodeToTempDirWhether to use temporary files when creating messages.
IncludeHeadersWhether headers are included when posting to a file.
LogDebugWhether to log debug data.
LogFilenameThe base name of the log file.
LogOptionsThe information to be written to log files.
MDNDispositionReturns the Disposition header of the MDN.
MessageHeadersReturns the headers of the message.
NormalizeMICWhether to normalize line endings before calculating the MIC.
OAEPMGF1HashAlgorithmThe MGF1 hash algorithm used when encrypting a key.
OAEPParamsThe hex encoded OAEP parameters to be used when encrypting a key.
OAEPRSAHashAlgorithmThe RSA hash algorithm used when encrypting a key.
PasswordA password if authentication is to be used.
PostToFileCreates the message on disk.
RequiredSignatureAlgorithmsSpecifies a list of acceptable signature algorithms.
UserA user name if authentication is to be used.
AcceptEncodingUsed to tell the server which types of content encodings the client supports.
AllowHTTPCompressionThis property enables HTTP compression for receiving data.
AllowHTTPFallbackWhether HTTP/2 connections are permitted to fallback to HTTP/1.1.
AppendWhether to append data to LocalFile.
AuthorizationThe Authorization string to be sent to the server.
BytesTransferredContains the number of bytes transferred in the response data.
ChunkSizeSpecifies the chunk size in bytes when using chunked encoding.
CompressHTTPRequestSet to true to compress the body of a PUT or POST request.
EncodeURLIf set to true the URL will be encoded by the class.
FollowRedirectsDetermines what happens when the server issues a redirect.
GetOn302RedirectIf set to true the class will perform a GET on the new location.
HTTP2HeadersWithoutIndexingHTTP2 headers that should not update the dynamic header table with incremental indexing.
HTTPVersionThe version of HTTP used by the class.
IfModifiedSinceA date determining the maximum age of the desired document.
KeepAliveDetermines whether the HTTP connection is closed after completion of the request.
KerberosSPNThe Service Principal Name for the Kerberos Domain Controller.
LogLevelThe level of detail that is logged.
MaxRedirectAttemptsLimits the number of redirects that are followed in a request.
NegotiatedHTTPVersionThe negotiated HTTP version.
OtherHeadersOther headers as determined by the user (optional).
ProxyAuthorizationThe authorization string to be sent to the proxy server.
ProxyAuthSchemeThe authorization scheme to be used for the proxy.
ProxyPasswordA password if authentication is to be used for the proxy.
ProxyPortPort for the proxy server (default 80).
ProxyServerName or IP address of a proxy server (optional).
ProxyUserA user name if authentication is to be used for the proxy.
SentHeadersThe full set of headers as sent by the client.
StatusLineThe first line of the last response from the server.
TransferredDataThe contents of the last response from the server.
TransferredDataLimitThe maximum number of incoming bytes to be stored by the class.
TransferredHeadersThe full set of headers as received from the server.
TransferredRequestThe full request as sent by the client.
UseChunkedEncodingEnables or Disables HTTP chunked encoding for transfers.
UseIDNsWhether to encode hostnames to internationalized domain names.
UsePlatformHTTPClientWhether or not to use the platform HTTP client.
UserAgentInformation about the user agent (browser).
ConnectionTimeoutSets a separate timeout value for establishing a connection.
FirewallAutoDetectTells the class whether or not to automatically detect and use firewall system settings, if available.
FirewallHostName or IP address of firewall (optional).
FirewallPasswordPassword to be used if authentication is to be used when connecting through the firewall.
FirewallPortThe TCP port for the FirewallHost;.
FirewallTypeDetermines the type of firewall to connect through.
FirewallUserA user name if authentication is to be used connecting through a firewall.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
LingerWhen set to True, connections are terminated gracefully.
LingerTimeTime in seconds to have the connection linger.
LocalHostThe name of the local host through which connections are initiated or accepted.
LocalPortThe port in the local host where the class binds.
MaxLineLengthThe maximum amount of data to accumulate when no EOL is found.
MaxTransferRateThe transfer rate limit in bytes per second.
ProxyExceptionsListA semicolon separated list of hosts and IPs to bypass when using a proxy.
TCPKeepAliveDetermines whether or not the keep alive socket option is enabled.
TcpNoDelayWhether or not to delay when sending packets.
UseIPv6Whether to use IPv6.
LogSSLPacketsControls whether SSL packets are logged when using the internal security API.
OpenSSLCADirThe path to a directory containing CA certificates.
OpenSSLCAFileName of the file containing the list of CA's trusted by your application.
OpenSSLCipherListA string that controls the ciphers to be used by SSL.
OpenSSLPrngSeedDataThe data to seed the pseudo random number generator (PRNG).
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCACertFilePathsThe paths to CA certificate files on Unix/Linux.
SSLCACertsA newline separated list of CA certificate to use during SSL client authentication.
SSLCheckCRLWhether to check the Certificate Revocation List for the server certificate.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledCipherSuitesThe cipher suite to be used in an SSL negotiation.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLEnableRenegotiationWhether the renegotiation_info SSL extension is supported.
SSLIncludeCertChainWhether the entire certificate chain is included in the SSLServerAuthentication event.
SSLNegotiatedCipherReturns the negotiated ciphersuite.
SSLNegotiatedCipherStrengthReturns the negotiated ciphersuite strength.
SSLNegotiatedCipherSuiteReturns the negotiated ciphersuite.
SSLNegotiatedKeyExchangeReturns the negotiated key exchange algorithm.
SSLNegotiatedKeyExchangeStrengthReturns the negotiated key exchange algorithm strength.
SSLNegotiatedVersionReturns the negotiated protocol version.
SSLProviderThe name of the security provider to use.
SSLSecurityFlagsFlags that control certificate verification.
SSLServerCACertsA newline separated list of CA certificate to use during SSL server certificate validation.
TLS12SignatureAlgorithmsDefines the allowed TLS 1.2 signature algorithms when UseInternalSecurityAPI is True.
TLS12SupportedGroupsThe supported groups for ECC.
TLS13KeyShareGroupsThe groups for which to pregenerate key shares.
TLS13SignatureAlgorithmsThe allowed certificate signature algorithms.
TLS13SupportedGroupsThe supported groups for (EC)DHE key exchange.
AbsoluteTimeoutDetermines whether timeouts are inactivity timeouts or absolute timeouts.
FirewallDataUsed to send extra data to the firewall.
InBufferSizeThe size in bytes of the incoming queue of the socket.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks EDI 2020 Python Edition - Version 20.0 [Build 8203]