---

- name: Export Cert from qxldod
  win_shell: '$cert = (Get-AuthenticodeSignature "{{ virtio_win_virtio_path }}\qxldod\{{ virtio_driver_directory }}\amd64\qxldod.cat").SignerCertificate; [System.IO.File]::WriteAllBytes("{{ ansible_env.TEMP }}\redhat_qxldod.cer", $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert));'
  when: virtio_driver_directory != '2k8R2'

- name: Export Cert from qxl
  win_shell: '$cert = (Get-AuthenticodeSignature "{{ virtio_win_virtio_path }}\qxl\{{ virtio_driver_directory }}\amd64\qxl.cat").SignerCertificate; [System.IO.File]::WriteAllBytes("{{ ansible_env.TEMP }}\redhat_qxldod.cer", $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert));'
  when: virtio_driver_directory == '2k8R2'

- name: Export Cert from balloon
  win_shell: '$cert = (Get-AuthenticodeSignature "{{ virtio_win_virtio_path }}\Balloon\{{ virtio_driver_directory }}\amd64\blnsvr.exe").SignerCertificate; [System.IO.File]::WriteAllBytes("{{ ansible_env.TEMP }}\redhat_balloon.cer", $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert));'

- name: Install RH certificate (qxldod) to TrustedPublisher certificate store
  win_command: 'certutil.exe -f -addstore "TrustedPublisher" {{ ansible_env.TEMP }}\redhat_qxldod.cer'
  notify:
    - Delete downloaded

- name: Install RH certificate (Balloon) to TrustedPublisher certificate store
  win_command: 'certutil.exe -f -addstore "TrustedPublisher" {{ ansible_env.TEMP }}\redhat_balloon.cer'
  notify:
    - Delete downloaded