Skip to content

Instantly share code, notes, and snippets.

@marcodebe
Last active June 30, 2025 15:40
Show Gist options
  • Save marcodebe/6138525 to your computer and use it in GitHub Desktop.
Save marcodebe/6138525 to your computer and use it in GitHub Desktop.

Revisions

  1. marcodebe revised this gist Nov 30, 2024. No changes.
  2. marcodebe revised this gist Nov 30, 2024. No changes.
  3. marcodebe revised this gist Nov 25, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion aruba-sign.py
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    import sys
    import os

    WSDL = 'https://firmaautomatica.aruba.it/ArubaSignService/ArubaSignService?WSDL'
    WSDL = 'https://arss.arubapec.it/ArubaSignService/ArubaSignService?wsdl'

    document = sys.argv[1]
    otp = sys.argv[2]
  4. marcodebe revised this gist Apr 23, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions aruba-sign.py
    Original file line number Diff line number Diff line change
    @@ -12,13 +12,13 @@
    sign_request = factory.signRequestV2(
    requiredmark=True,
    transport='BYNARYNET',
    binaryinput=open(sys.argv[1], 'rb').read(),
    binaryinput=open(document, 'rb').read(),
    identity=factory.auth(
    user='username',
    userPWD=3141592653,
    typeHSM='cosign',
    typeOtpAuth='frAzienda',
    otpPwd=sys.argv[2]
    otpPwd=otp
    ))

    response = client.service.pdfsignatureV2(SignRequestV2=sign_request)
  5. marcodebe renamed this gist Apr 23, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. marcodebe revised this gist Apr 23, 2019. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion aruba-sign
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,12 @@
    from zeep import Client
    import sys
    import os

    WSDL = 'https://firmaautomatica.aruba.it/ArubaSignService/ArubaSignService?WSDL'

    document = sys.argv[1]
    otp = sys.argv[2]
    output = '.signed'.join(os.path.splitext(document))
    client = Client(WSDL)
    factory = client.type_factory('ns0')
    sign_request = factory.signRequestV2(
    @@ -18,5 +22,5 @@ sign_request = factory.signRequestV2(
    ))

    response = client.service.pdfsignatureV2(SignRequestV2=sign_request)
    outputfile = open('output.pdf', 'wb')
    outputfile = open(output, 'wb')
    outputfile.write(response.binaryoutput)
  7. marcodebe revised this gist Apr 23, 2019. 1 changed file with 20 additions and 42 deletions.
    62 changes: 20 additions & 42 deletions aruba-sign
    Original file line number Diff line number Diff line change
    @@ -1,44 +1,22 @@
    from suds.client import Client
    from hashlib import sha256
    from zeep import Client
    import sys

    url = 'https://firmaautomatica.aruba.it/ArubaSignService/ArubaSignService?WSDL'
    client = Client(url)
    identity = client.factory.create('identity')

    identity.typeHSM = 'COSIGN'
    identity.typeOtpAuth = 'firma'
    identity.user = 'username'
    identity.userPWD = 'password'

    # Get the OTP from stdin
    identity.otpPwd = sys.argv[1]


    def pades(data):
    """ Sign the document.

    :param data: PDF to be signed
    :returns: PDF signed
    """"

    request = client.factory.create('SignRequestV2')
    request.identity = identity
    request.certID = 'FOO'
    request.binaryinput = data.encode('base64')
    request.transport.value = 'BYNARYNET'

    # With timestamp
    request.requiredmark = True

    response = client.service.pdfsignatureV2(request)

    if response.status == "OK":
    return response.binaryoutput.decode('base64')


    def main():
    signme = open('input.pdf', 'r')
    outputfile = open('output.pdf', 'w')
    outputfile.write(pades(signme.read()))
    outputfile.close()
    WSDL = 'https://firmaautomatica.aruba.it/ArubaSignService/ArubaSignService?WSDL'

    client = Client(WSDL)
    factory = client.type_factory('ns0')
    sign_request = factory.signRequestV2(
    requiredmark=True,
    transport='BYNARYNET',
    binaryinput=open(sys.argv[1], 'rb').read(),
    identity=factory.auth(
    user='username',
    userPWD=3141592653,
    typeHSM='cosign',
    typeOtpAuth='frAzienda',
    otpPwd=sys.argv[2]
    ))

    response = client.service.pdfsignatureV2(SignRequestV2=sign_request)
    outputfile = open('output.pdf', 'wb')
    outputfile.write(response.binaryoutput)
  8. marcodebe revised this gist Mar 28, 2014. 1 changed file with 4 additions and 6 deletions.
    10 changes: 4 additions & 6 deletions aruba-sign
    Original file line number Diff line number Diff line change
    @@ -27,13 +27,11 @@ def pades(data):
    request.certID = 'FOO'
    request.binaryinput = data.encode('base64')
    request.transport.value = 'BYNARYNET'

    # With timestamp
    request.requiredmark = True

    app = client.factory.create('pdfSignApparence')
    app.location = "Bogliasco - Genova"
    app.reason = "No reason"
    app.page = 1

    response = client.service.pdfsignatureV2(request, app)
    response = client.service.pdfsignatureV2(request)

    if response.status == "OK":
    return response.binaryoutput.decode('base64')
  9. marcodebe revised this gist Aug 2, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion aruba-sign
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ def pades(data):

    request = client.factory.create('SignRequestV2')
    request.identity = identity
    request.certID = 'AS0'
    request.certID = 'FOO'
    request.binaryinput = data.encode('base64')
    request.transport.value = 'BYNARYNET'

  10. marcodebe revised this gist Aug 2, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions aruba-sign
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ identity.otpPwd = sys.argv[1]
    def pades(data):
    """ Sign the document.

    :param data: base64 of PDF to be signed
    :param data: PDF to be signed
    :returns: PDF signed
    """"

    @@ -40,7 +40,7 @@ def pades(data):


    def main():
    encodeme = open('input.pdf', 'r')
    signme = open('input.pdf', 'r')
    outputfile = open('output.pdf', 'w')
    outputfile.write(pades(encodeme.read()))
    outputfile.write(pades(signme.read()))
    outputfile.close()
  11. marcodebe revised this gist Aug 2, 2013. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions aruba-sign
    Original file line number Diff line number Diff line change
    @@ -16,6 +16,11 @@ identity.otpPwd = sys.argv[1]


    def pades(data):
    """ Sign the document.

    :param data: base64 of PDF to be signed
    :returns: PDF signed
    """"

    request = client.factory.create('SignRequestV2')
    request.identity = identity
  12. marcodebe revised this gist Aug 2, 2013. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion aruba-sign
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,6 @@ def pades(data):

    def main():
    encodeme = open('input.pdf', 'r')

    outputfile = open('output.pdf', 'w')
    outputfile.write(pades(encodeme.read()))
    outputfile.close()
  13. marcodebe revised this gist Aug 2, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions aruba-sign
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@ identity.typeOtpAuth = 'firma'
    identity.user = 'username'
    identity.userPWD = 'password'

    # Get the OTP from stdin
    identity.otpPwd = sys.argv[1]


  14. marcodebe created this gist Aug 2, 2013.
    41 changes: 41 additions & 0 deletions aruba-sign
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    from suds.client import Client
    from hashlib import sha256
    import sys

    url = 'https://firmaautomatica.aruba.it/ArubaSignService/ArubaSignService?WSDL'
    client = Client(url)
    identity = client.factory.create('identity')

    identity.typeHSM = 'COSIGN'
    identity.typeOtpAuth = 'firma'
    identity.user = 'username'
    identity.userPWD = 'password'

    identity.otpPwd = sys.argv[1]


    def pades(data):

    request = client.factory.create('SignRequestV2')
    request.identity = identity
    request.certID = 'AS0'
    request.binaryinput = data.encode('base64')
    request.transport.value = 'BYNARYNET'

    app = client.factory.create('pdfSignApparence')
    app.location = "Bogliasco - Genova"
    app.reason = "No reason"
    app.page = 1

    response = client.service.pdfsignatureV2(request, app)

    if response.status == "OK":
    return response.binaryoutput.decode('base64')


    def main():
    encodeme = open('input.pdf', 'r')

    outputfile = open('output.pdf', 'w')
    outputfile.write(pades(encodeme.read()))
    outputfile.close()