<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comentarios en: Cómo firmar un documento PDF desde C# con iTextSharp</title>
	<atom:link href="http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/</link>
	<description>Blog de Scientia® Soluciones Informaticas</description>
	<lastBuildDate>Wed, 08 Feb 2012 16:50:55 -0200</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>Por: Jaime</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-1747</link>
		<dc:creator>Jaime</dc:creator>
		<pubDate>Mon, 12 Sep 2011 22:36:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-1747</guid>
		<description>Supongo que lo habréis solucionado, pero lo de que en la web no os funcione, fijo que es por el usuario que está ejecutando el contexto de seguridad de la aplicación ( AppPool ). Para utilizarlo, deberéis instalar el certificado en el MYCOMPUTER desde certMngr.msc . Si necesitáis algo, podéis localizarme en jcastello@gmail.com.</description>
		<content:encoded><![CDATA[<p>Supongo que lo habréis solucionado, pero lo de que en la web no os funcione, fijo que es por el usuario que está ejecutando el contexto de seguridad de la aplicación ( AppPool ). Para utilizarlo, deberéis instalar el certificado en el MYCOMPUTER desde certMngr.msc . Si necesitáis algo, podéis localizarme en <a href="mailto:jcastello@gmail.com">jcastello@gmail.com</a>.
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_1747" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c1747" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c1747" class="gdsr_rating_as"><a id="gdsrX1747X5X0XcXcomment_rater_1747Xcomment_loader_1747" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX1747X4X0XcXcomment_rater_1747Xcomment_loader_1747" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX1747X3X0XcXcomment_rater_1747Xcomment_loader_1747" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX1747X2X0XcXcomment_rater_1747Xcomment_loader_1747" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX1747X1X0XcXcomment_rater_1747Xcomment_loader_1747" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_1747" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c1747" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Alberto Dolmann</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-1231</link>
		<dc:creator>Alberto Dolmann</dc:creator>
		<pubDate>Thu, 30 Jun 2011 13:19:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-1231</guid>
		<description>Buenas, queria saber si puedo encontrar algun enlace ? que me permita solucionar el mismo problema que tiene Alberto Pérez, de firmar un documento desde una aplicación Web.  Estoy con la opcion 1 (&quot;La clave no existe&quot;).  Muchas Gracias</description>
		<content:encoded><![CDATA[<p>Buenas, queria saber si puedo encontrar algun enlace ? que me permita solucionar el mismo problema que tiene Alberto Pérez, de firmar un documento desde una aplicación Web.  Estoy con la opcion 1 (&#8220;La clave no existe&#8221;).  Muchas Gracias
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_1231" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c1231" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c1231" class="gdsr_rating_as"><a id="gdsrX1231X5X0XcXcomment_rater_1231Xcomment_loader_1231" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX1231X4X0XcXcomment_rater_1231Xcomment_loader_1231" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX1231X3X0XcXcomment_rater_1231Xcomment_loader_1231" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX1231X2X0XcXcomment_rater_1231Xcomment_loader_1231" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX1231X1X0XcXcomment_rater_1231Xcomment_loader_1231" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_1231" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c1231" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Roberto</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-1219</link>
		<dc:creator>Roberto</dc:creator>
		<pubDate>Mon, 27 Jun 2011 16:32:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-1219</guid>
		<description>Sobre el error en preclose os dejo el codigo en c#



Dictionary objTable = new Dictionary() ;

debereis incluir el using
using System.Collections.Generic;</description>
		<content:encoded><![CDATA[<p>Sobre el error en preclose os dejo el codigo en c#</p>
<p>Dictionary objTable = new Dictionary() ;</p>
<p>debereis incluir el using<br />
using System.Collections.Generic;
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_1219" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c1219" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c1219" class="gdsr_rating_as"><a id="gdsrX1219X5X0XcXcomment_rater_1219Xcomment_loader_1219" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX1219X4X0XcXcomment_rater_1219Xcomment_loader_1219" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX1219X3X0XcXcomment_rater_1219Xcomment_loader_1219" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX1219X2X0XcXcomment_rater_1219Xcomment_loader_1219" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX1219X1X0XcXcomment_rater_1219Xcomment_loader_1219" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_1219" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c1219" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Gustavo Cantero (The Wolf)</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-281</link>
		<dc:creator>Gustavo Cantero (The Wolf)</dc:creator>
		<pubDate>Fri, 18 Mar 2011 19:14:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-281</guid>
		<description>Hola, Fabio.
El problema que te da sobre &quot;The current session is not interactive&quot; seguramente sea porque estás intentando abrir el diálogo de selección de certificado del lado del servidor, lo cual no se puede.  Si necesitas hacer que el usuario pueda firmar un documento utilizando una aplicación web lo mejor (si no es la única manera) es hacerlo a través de un control COM (con C++ o el viejo Visual Basic 6) ya que sino no vas a poder acceder al repositorio de certificados del cliente.  Otra opción es utilizando Silverlight, con el cual aunque no puedas acceder al repositorio (a no ser que sea una aplicación out-of-browser) podés hacer que el usuario elija un archivo donde tiene su certificado y con eso firmarlo del lado del cliente (nosotro hemos hecho un proyecto así).
Sobre la selección del certificado para el acceso a un servicio web: esto lo podés hacer configurando el IIS.  En esta página te explica un poco mejor cómo hacerlo con IIS 7: &lt;a href=&quot;http://technet.microsoft.com/es-ar/library/cc732996(WS.10).aspx&quot; rel=&quot;nofollow&quot;&gt;Configurar la autenticación de asignaciones de certificado de cliente (IIS 7)&lt;/a&gt;.
Saludos.</description>
		<content:encoded><![CDATA[<p>Hola, Fabio.<br />
El problema que te da sobre &#8220;The current session is not interactive&#8221; seguramente sea porque estás intentando abrir el diálogo de selección de certificado del lado del servidor, lo cual no se puede.  Si necesitas hacer que el usuario pueda firmar un documento utilizando una aplicación web lo mejor (si no es la única manera) es hacerlo a través de un control COM (con C++ o el viejo Visual Basic 6) ya que sino no vas a poder acceder al repositorio de certificados del cliente.  Otra opción es utilizando Silverlight, con el cual aunque no puedas acceder al repositorio (a no ser que sea una aplicación out-of-browser) podés hacer que el usuario elija un archivo donde tiene su certificado y con eso firmarlo del lado del cliente (nosotro hemos hecho un proyecto así).<br />
Sobre la selección del certificado para el acceso a un servicio web: esto lo podés hacer configurando el IIS.  En esta página te explica un poco mejor cómo hacerlo con IIS 7: <a href="http://technet.microsoft.com/es-ar/library/cc732996(WS.10).aspx" rel="nofollow">Configurar la autenticación de asignaciones de certificado de cliente (IIS 7)</a>.<br />
Saludos.
<div class="ratingblock ">
<div style="display: none">VN:F [1.7.3_972]</div>
<div id="comment_rater_281" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c281" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c281" class="gdsr_rating_as"><a id="gdsrX281X5X0XcXcomment_rater_281Xcomment_loader_281" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX281X4X0XcXcomment_rater_281Xcomment_loader_281" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX281X3X0XcXcomment_rater_281Xcomment_loader_281" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX281X2X0XcXcomment_rater_281Xcomment_loader_281" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX281X1X0XcXcomment_rater_281Xcomment_loader_281" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_281" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c281" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Fábio Freitas</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-280</link>
		<dc:creator>Fábio Freitas</dc:creator>
		<pubDate>Fri, 18 Mar 2011 19:01:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-280</guid>
		<description>Hola Gustavo,

En primer lugar enhorabuena por tu artículo.

Me pregunto si podemos abrir la pantalla para seleccionar un certificado digital en una aplicación web, de modo que firma un archivo XML y el acceso a un servicio Web?

Traté de alguna manera y cuando llegué a más regalos de error siguiente:

The current session is not interactive

Le doy las gracias,

Abrazos</description>
		<content:encoded><![CDATA[<p>Hola Gustavo,</p>
<p>En primer lugar enhorabuena por tu artículo.</p>
<p>Me pregunto si podemos abrir la pantalla para seleccionar un certificado digital en una aplicación web, de modo que firma un archivo XML y el acceso a un servicio Web?</p>
<p>Traté de alguna manera y cuando llegué a más regalos de error siguiente:</p>
<p>The current session is not interactive</p>
<p>Le doy las gracias,</p>
<p>Abrazos
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_280" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c280" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c280" class="gdsr_rating_as"><a id="gdsrX280X5X0XcXcomment_rater_280Xcomment_loader_280" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX280X4X0XcXcomment_rater_280Xcomment_loader_280" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX280X3X0XcXcomment_rater_280Xcomment_loader_280" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX280X2X0XcXcomment_rater_280Xcomment_loader_280" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX280X1X0XcXcomment_rater_280Xcomment_loader_280" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_280" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c280" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: willi</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-227</link>
		<dc:creator>willi</dc:creator>
		<pubDate>Thu, 28 Oct 2010 00:40:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-227</guid>
		<description>Hola Tengo el siguiente mensaje de error, alguien podria ayudarme...!!!!!

  Dim intCSize As Integer = 4000
  Dim exc As New Dictionary(Of PdfName, Integer)()
  exc(PdfName.CONTENTS) = intCSize * 2 + 2
  sap.PreClose(exc)

Se cae en la ultima linea PreClose!!!

---------------------------
prySignDig
---------------------------
ERROR: System.NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.

   en iTextSharp.text.pdf.PdfPKCS7.GetSubjectFields(X509Certificate cert)

   en iTextSharp.text.pdf.PdfSignatureAppearance.GetAppearance()

   en iTextSharp.text.pdf.PdfSignatureAppearance.PreClose(Dictionary`2 exclusionSizes)

   en prySignDig.frmSignDig02.btnPrueba_Click(Object sender, EventArgs e) en D:\prySignDig08\prySignDig\frmSignDig02.vb:línea 102</description>
		<content:encoded><![CDATA[<p>Hola Tengo el siguiente mensaje de error, alguien podria ayudarme&#8230;!!!!!</p>
<p>  Dim intCSize As Integer = 4000<br />
  Dim exc As New Dictionary(Of PdfName, Integer)()<br />
  exc(PdfName.CONTENTS) = intCSize * 2 + 2<br />
  sap.PreClose(exc)</p>
<p>Se cae en la ultima linea PreClose!!!</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
prySignDig<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
ERROR: System.NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.</p>
<p>   en iTextSharp.text.pdf.PdfPKCS7.GetSubjectFields(X509Certificate cert)</p>
<p>   en iTextSharp.text.pdf.PdfSignatureAppearance.GetAppearance()</p>
<p>   en iTextSharp.text.pdf.PdfSignatureAppearance.PreClose(Dictionary`2 exclusionSizes)</p>
<p>   en prySignDig.frmSignDig02.btnPrueba_Click(Object sender, EventArgs e) en D:\prySignDig08\prySignDig\frmSignDig02.vb:línea 102
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_227" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c227" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c227" class="gdsr_rating_as"><a id="gdsrX227X5X0XcXcomment_rater_227Xcomment_loader_227" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX227X4X0XcXcomment_rater_227Xcomment_loader_227" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX227X3X0XcXcomment_rater_227Xcomment_loader_227" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX227X2X0XcXcomment_rater_227Xcomment_loader_227" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX227X1X0XcXcomment_rater_227Xcomment_loader_227" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_227" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c227" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: karina</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-223</link>
		<dc:creator>karina</dc:creator>
		<pubDate>Thu, 21 Oct 2010 23:06:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-223</guid>
		<description>disculpa si solo kiero leer la firma desde un  windows form 
no sabrias como poder hacerle?
en un crystal report</description>
		<content:encoded><![CDATA[<p>disculpa si solo kiero leer la firma desde un  windows form<br />
no sabrias como poder hacerle?<br />
en un crystal report
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_223" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c223" style="width: 60px;" class="gdinner"></div>
<div id="gdr_stars_c223" class="gdsr_rating_as"><a id="gdsrX223X5X0XcXcomment_rater_223Xcomment_loader_223" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX223X4X0XcXcomment_rater_223Xcomment_loader_223" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX223X3X0XcXcomment_rater_223Xcomment_loader_223" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX223X2X0XcXcomment_rater_223Xcomment_loader_223" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX223X1X0XcXcomment_rater_223Xcomment_loader_223" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_223" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c223" class=" comment">Rating: 5.0/<strong>5</strong> (1 voto cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Alberto Pérez</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-221</link>
		<dc:creator>Alberto Pérez</dc:creator>
		<pubDate>Fri, 15 Oct 2010 10:21:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-221</guid>
		<description>Hola Gustavo,
despues de un tiempo continúo trabajando el tema de la firma digital de pdf.
Me dicen que no es posible lo que quiero hacer.
Mi idea: 
Tener un pdf en el servidor web &gt; El usuario lo selecciona &gt; Clica el botón de firmar &gt; Selecciona su certificado digital &gt; y OK &gt; El pdf firmado se queda en el servidor.
Pues me dicen que no es posible firmar en el servidor con un certificado de cliente ya que la clave privada no puede viajar. Eso es cierto? Alguien tiene alguna idea de como podría hacerlo? o una aplicación WEB que haga esto.
Yo buscaba algo parecido a lo que realiza Portasigma.com (firma online)</description>
		<content:encoded><![CDATA[<p>Hola Gustavo,<br />
despues de un tiempo continúo trabajando el tema de la firma digital de pdf.<br />
Me dicen que no es posible lo que quiero hacer.<br />
Mi idea:<br />
Tener un pdf en el servidor web &gt; El usuario lo selecciona &gt; Clica el botón de firmar &gt; Selecciona su certificado digital &gt; y OK &gt; El pdf firmado se queda en el servidor.<br />
Pues me dicen que no es posible firmar en el servidor con un certificado de cliente ya que la clave privada no puede viajar. Eso es cierto? Alguien tiene alguna idea de como podría hacerlo? o una aplicación WEB que haga esto.<br />
Yo buscaba algo parecido a lo que realiza Portasigma.com (firma online)
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_221" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c221" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c221" class="gdsr_rating_as"><a id="gdsrX221X5X0XcXcomment_rater_221Xcomment_loader_221" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX221X4X0XcXcomment_rater_221Xcomment_loader_221" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX221X3X0XcXcomment_rater_221Xcomment_loader_221" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX221X2X0XcXcomment_rater_221Xcomment_loader_221" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX221X1X0XcXcomment_rater_221Xcomment_loader_221" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_221" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c221" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Miguel</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-208</link>
		<dc:creator>Miguel</dc:creator>
		<pubDate>Fri, 17 Sep 2010 11:46:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-208</guid>
		<description>Hola.
Estoy desarrollando un proyecto en el cual añado una imagen y un texto a cada hoja del PDF. Éste viene firmado. 

Para escribir en cada página, lo que hago básicamente es recorrer página a página, e ir creando nuevas páginas en un nuevo archivo e insertado el &quot;contexto&quot; (es decir, el contenido original) más lo que añado.

El caso es que la 1º página viene firmada, y no se como extaer la firma (que quedaría invalida, pero me sirve) y colocarla en la 1º página del nuevo archivo)

Alguna pista??

Gracias y un saludo</description>
		<content:encoded><![CDATA[<p>Hola.<br />
Estoy desarrollando un proyecto en el cual añado una imagen y un texto a cada hoja del PDF. Éste viene firmado. </p>
<p>Para escribir en cada página, lo que hago básicamente es recorrer página a página, e ir creando nuevas páginas en un nuevo archivo e insertado el &#8220;contexto&#8221; (es decir, el contenido original) más lo que añado.</p>
<p>El caso es que la 1º página viene firmada, y no se como extaer la firma (que quedaría invalida, pero me sirve) y colocarla en la 1º página del nuevo archivo)</p>
<p>Alguna pista??</p>
<p>Gracias y un saludo
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_208" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c208" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c208" class="gdsr_rating_as"><a id="gdsrX208X5X0XcXcomment_rater_208Xcomment_loader_208" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX208X4X0XcXcomment_rater_208Xcomment_loader_208" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX208X3X0XcXcomment_rater_208Xcomment_loader_208" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX208X2X0XcXcomment_rater_208Xcomment_loader_208" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX208X1X0XcXcomment_rater_208Xcomment_loader_208" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_208" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c208" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Gustavo Cantero (The Wolf)</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-204</link>
		<dc:creator>Gustavo Cantero (The Wolf)</dc:creator>
		<pubDate>Tue, 10 Aug 2010 14:01:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-204</guid>
		<description>El proyecto de ejemplo tiene la misma clase que muestro en este artículo, pero tiene una ventana para ingresar el PDF a firmar y poder probar más rápido esta clase.
Cualquier otra consulta no dudes en escribirla aquí.
Suerte!</description>
		<content:encoded><![CDATA[<p>El proyecto de ejemplo tiene la misma clase que muestro en este artículo, pero tiene una ventana para ingresar el PDF a firmar y poder probar más rápido esta clase.<br />
Cualquier otra consulta no dudes en escribirla aquí.<br />
Suerte!
<div class="ratingblock ">
<div style="display: none">VN:F [1.7.3_972]</div>
<div id="comment_rater_204" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c204" style="width: 60px;" class="gdinner"></div>
<div id="gdr_stars_c204" class="gdsr_rating_as"><a id="gdsrX204X5X0XcXcomment_rater_204Xcomment_loader_204" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX204X4X0XcXcomment_rater_204Xcomment_loader_204" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX204X3X0XcXcomment_rater_204Xcomment_loader_204" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX204X2X0XcXcomment_rater_204Xcomment_loader_204" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX204X1X0XcXcomment_rater_204Xcomment_loader_204" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_204" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c204" class=" comment">Rating: 5.0/<strong>5</strong> (1 voto cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Juan</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-203</link>
		<dc:creator>Juan</dc:creator>
		<pubDate>Tue, 10 Aug 2010 08:04:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-203</guid>
		<description>Gracias gustavo, ando buscando una manera para firmar pdf&#039;s yme ha parecido simple...voy a probarlo...¿El ejemplo valido es el que has puesto para descargar?....</description>
		<content:encoded><![CDATA[<p>Gracias gustavo, ando buscando una manera para firmar pdf&#8217;s yme ha parecido simple&#8230;voy a probarlo&#8230;¿El ejemplo valido es el que has puesto para descargar?&#8230;.
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_203" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c203" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c203" class="gdsr_rating_as"><a id="gdsrX203X5X0XcXcomment_rater_203Xcomment_loader_203" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX203X4X0XcXcomment_rater_203Xcomment_loader_203" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX203X3X0XcXcomment_rater_203Xcomment_loader_203" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX203X2X0XcXcomment_rater_203Xcomment_loader_203" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX203X1X0XcXcomment_rater_203Xcomment_loader_203" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_203" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c203" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Gustavo Cantero (The Wolf)</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-202</link>
		<dc:creator>Gustavo Cantero (The Wolf)</dc:creator>
		<pubDate>Mon, 09 Aug 2010 19:03:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-202</guid>
		<description>El proyecto está hecho en Visual Studio 2008 con C#, pero se podría pasar facilmente a un proyecto de Visual Basic.NET con Visual Studio 2005.
Podrías probar con esta herramienta para migrar código C# a VB.NET: &lt;a href=&quot;http://www.developerfusion.com/tools/convert/csharp-to-vb&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://www.developerfusion.com/tools/convert/csharp-to-vb&lt;/a&gt;.
Cualquier consulta no dudes en escribirla aquí.
Suerte!</description>
		<content:encoded><![CDATA[<p>El proyecto está hecho en Visual Studio 2008 con C#, pero se podría pasar facilmente a un proyecto de Visual Basic.NET con Visual Studio 2005.<br />
Podrías probar con esta herramienta para migrar código C# a VB.NET: <a href="http://www.developerfusion.com/tools/convert/csharp-to-vb" target="_blank" rel="nofollow">http://www.developerfusion.com/tools/convert/csharp-to-vb</a>.<br />
Cualquier consulta no dudes en escribirla aquí.<br />
Suerte!
<div class="ratingblock ">
<div style="display: none">VN:F [1.7.3_972]</div>
<div id="comment_rater_202" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c202" style="width: 60px;" class="gdinner"></div>
<div id="gdr_stars_c202" class="gdsr_rating_as"><a id="gdsrX202X5X0XcXcomment_rater_202Xcomment_loader_202" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX202X4X0XcXcomment_rater_202Xcomment_loader_202" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX202X3X0XcXcomment_rater_202Xcomment_loader_202" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX202X2X0XcXcomment_rater_202Xcomment_loader_202" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX202X1X0XcXcomment_rater_202Xcomment_loader_202" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_202" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c202" class=" comment">Rating: 5.0/<strong>5</strong> (1 voto cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Juan</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-201</link>
		<dc:creator>Juan</dc:creator>
		<pubDate>Mon, 09 Aug 2010 18:17:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-201</guid>
		<description>¿Estos ejejmplos corren con Vb2005?</description>
		<content:encoded><![CDATA[<p>¿Estos ejejmplos corren con Vb2005?
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_201" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c201" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c201" class="gdsr_rating_as"><a id="gdsrX201X5X0XcXcomment_rater_201Xcomment_loader_201" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX201X4X0XcXcomment_rater_201Xcomment_loader_201" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX201X3X0XcXcomment_rater_201Xcomment_loader_201" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX201X2X0XcXcomment_rater_201Xcomment_loader_201" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX201X1X0XcXcomment_rater_201Xcomment_loader_201" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_201" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c201" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Gustavo Cantero (The Wolf)</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-200</link>
		<dc:creator>Gustavo Cantero (The Wolf)</dc:creator>
		<pubDate>Fri, 06 Aug 2010 12:38:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-200</guid>
		<description>Hola, Alberto.  Si, como dices, no puedes utilizar la interfaz desde una aplicación web.
Sobre el punto 1, seguramente el problema sea que el certificado a utilizar lo tienes instalado en un repositorio de usario, por lo tanto, cuando la aplicación se ejecuta en producción no lo encuentra.  Prueba instalando tu certificado (con la clave privada) en un repositorio de la máquina (no de usuario) en el servidor utilizando la herramienta &quot;certmgr&quot;.  En este artículo muestro un ejemplo de cómo hacerlo: &lt;a target=&quot;_blank&quot; href=&quot;http://www.programandoamedianoche.com/2009/06/crear-certificados-de-prueba-para-servidor-y-cliente/&quot; rel=&quot;nofollow&quot;&gt;Crear certificados de prueba para servidor y cliente&lt;/a&gt;.
Suerte!</description>
		<content:encoded><![CDATA[<p>Hola, Alberto.  Si, como dices, no puedes utilizar la interfaz desde una aplicación web.<br />
Sobre el punto 1, seguramente el problema sea que el certificado a utilizar lo tienes instalado en un repositorio de usario, por lo tanto, cuando la aplicación se ejecuta en producción no lo encuentra.  Prueba instalando tu certificado (con la clave privada) en un repositorio de la máquina (no de usuario) en el servidor utilizando la herramienta &#8220;certmgr&#8221;.  En este artículo muestro un ejemplo de cómo hacerlo: <a target="_blank" href="http://www.programandoamedianoche.com/2009/06/crear-certificados-de-prueba-para-servidor-y-cliente/" rel="nofollow">Crear certificados de prueba para servidor y cliente</a>.<br />
Suerte!
<div class="ratingblock ">
<div style="display: none">VN:F [1.7.3_972]</div>
<div id="comment_rater_200" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c200" style="width: 60px;" class="gdinner"></div>
<div id="gdr_stars_c200" class="gdsr_rating_as"><a id="gdsrX200X5X0XcXcomment_rater_200Xcomment_loader_200" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX200X4X0XcXcomment_rater_200Xcomment_loader_200" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX200X3X0XcXcomment_rater_200Xcomment_loader_200" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX200X2X0XcXcomment_rater_200Xcomment_loader_200" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX200X1X0XcXcomment_rater_200Xcomment_loader_200" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_200" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c200" class=" comment">Rating: 5.0/<strong>5</strong> (1 voto cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Alberto Pérez</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-199</link>
		<dc:creator>Alberto Pérez</dc:creator>
		<pubDate>Fri, 06 Aug 2010 11:21:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-199</guid>
		<description>Hola Gustavo y compañía.
He visto que has dejado un proyecto para descargar y probar (funciona perfectamente) y creo que he encontrado el porque de uno de los dos errores que me dan.
El error (OPCION 2) que comento anteriormente se debe a que está utilizando X509Certificate2UI que solo se puede utilizar en una aplicación interactiva, como aplicaciones de WINDOWS FORMS.
Esta funcion muestra la interfaz de usuario cuadros de dialogo que le permiten seleccionar y ver los certificados X.509.
Esto no puede ser utilizado en APLICACIONES WEB asp.net (que es lo que estoy creando)
Ahora solo me queda la opción 1, guardar la clave y poder usarla.. si alguien sabe como ¿?</description>
		<content:encoded><![CDATA[<p>Hola Gustavo y compañía.<br />
He visto que has dejado un proyecto para descargar y probar (funciona perfectamente) y creo que he encontrado el porque de uno de los dos errores que me dan.<br />
El error (OPCION 2) que comento anteriormente se debe a que está utilizando X509Certificate2UI que solo se puede utilizar en una aplicación interactiva, como aplicaciones de WINDOWS FORMS.<br />
Esta funcion muestra la interfaz de usuario cuadros de dialogo que le permiten seleccionar y ver los certificados X.509.<br />
Esto no puede ser utilizado en APLICACIONES WEB asp.net (que es lo que estoy creando)<br />
Ahora solo me queda la opción 1, guardar la clave y poder usarla.. si alguien sabe como ¿?
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_199" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c199" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c199" class="gdsr_rating_as"><a id="gdsrX199X5X0XcXcomment_rater_199Xcomment_loader_199" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX199X4X0XcXcomment_rater_199Xcomment_loader_199" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX199X3X0XcXcomment_rater_199Xcomment_loader_199" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX199X2X0XcXcomment_rater_199Xcomment_loader_199" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX199X1X0XcXcomment_rater_199Xcomment_loader_199" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_199" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c199" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Alberto Pérez</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-198</link>
		<dc:creator>Alberto Pérez</dc:creator>
		<pubDate>Fri, 06 Aug 2010 09:17:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-198</guid>
		<description>Primero Hola JuanFran, yo el tema de &quot;System.Collections.Hashtable&quot;/&quot;System.Collections.Generic.Dictionary&quot; lo he &quot;solucionado (a mi me funciona)&quot; modificando el código.
Te lo dejo en VB.net que es lo que uso:
       &#039;Dim objTable As New Hashtable()
        Dim objTable As New Dictionary(Of PdfName, Integer)
        objTable(PdfName.CONTENTS) = intCSize * 2 + 2
        objSA.PreClose(objTable)
-----------------------------------------------
Hola Gustavo, estoy retomando el proyecto despues de unas vacacione si aún me encuentro algun problema, a ver si puedes ayudarme o cualquiera que pueda echarme una mano.

- Cuando estoy en desarrollo, el proyecto funciona bien (firma el pdf), pero cuando intento publicarlo en el servidor IIS me da algun fallo.
1-. (OPCION 1)Si publico el proyecto en un directorio virtual que SI requiere canal seguro SSL, a la hora de firmar el documento PDF me da el siguiente error:
&quot;La clave no existe&quot;
2-. (OPCION 2) Si publico el proyecto en un directorio virtual que NO requiere canal seguro SSL, al intentar acceder a la función GetCertificate me da el siguiente error:
&quot;The current session is not interactive&quot;

Os dejo el código en VB.net que estoy usando a ver si alguien da con la solución:

Imports System.Collections
Imports System.IO
Imports System.Security.Cryptography
Imports System.Security.Cryptography.Pkcs
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports Org.BouncyCastle.X509
Imports SysX509 = System.Security.Cryptography.X509Certificates

Imports System.Security
Imports System.Security.Cryptography.X509Certificates
Imports System.Security.Cryptography.X509Certificates.X509Certificate2

&#039;&#039;&#039; 
&#039;&#039;&#039; Helper para el firmado de PDFs con la librería iTextSharp
&#039;&#039;&#039; 
&#039;&#039;&#039; 
Partial Class FirmaDigital02
    Inherits System.Web.UI.Page

    Protected Sub btnSignDigital_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSignDigital.Click
        Try
            &#039;&#039;OPCIÓN 1: DIRECTORIO VIRTUAL IIS con SSL (requerir canal seguro)
            Dim objCertHttp As HttpClientCertificate
            objCertHttp = Request.ClientCertificate
            Dim certificate As X509Certificate2
            certificate = New System.Security.Cryptography.X509Certificates.X509Certificate2(objCertHttp.Certificate)
            &#039;certificate = New SysX509.X509Certificate2(objCertHttp.Certificate)
 
            &#039;&#039;OPCIÓN 2: VENTANA SELECCIÓN CERTIFICADO
            &#039;Dim certificate As X509Certificate2 = GetCertificate()

            Dim source As String = &quot;C:\Inetpub\wwwroot\TestVB\documents\signats\PruebaSignatura.pdf&quot;
            Dim target As String = &quot;C:\Inetpub\wwwroot\TestVB\documents\signats\PruebaSignatura_hashed2.pdf&quot;
            SignDigital.SignHashed(source, target, certificate, &quot;Razón&quot;, &quot;Localización&quot;, True)
            lblSignaPDF.Text = &quot;Finalitzat correctament. Comprobar signa&quot;
        Catch ex As Exception
            lblSignaPDF.Text = lblSignaPDF.Text &amp; &quot;Descripció error: &quot; &amp; ex.Message
        End Try
    End Sub



    Public Shared Function GetCertificate() As X509Certificate2
        Dim st As New X509Store(StoreName.My, StoreLocation.CurrentUser)

        st.Open(OpenFlags.[ReadOnly])
        Dim col As X509Certificate2Collection = st.Certificates
        Dim card As X509Certificate2 = Nothing

        Dim sel As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(col, &quot;Certificates&quot;, &quot;Seleccioni un certificat per a signar&quot;, X509SelectionFlag.SingleSelection)
        If sel.Count &gt; 0 Then
            Dim en As X509Certificate2Enumerator = sel.GetEnumerator()
            en.MoveNext()
            card = en.Current
        End If
        st.Close()
        Return card
    End Function

    &#039;Private Sub New()
    &#039;End Sub
    &#039;&#039;&#039; 
    &#039;&#039;&#039; Firma un documento
    &#039;&#039;&#039; 
    &#039;&#039;&#039; Documento origen
    &#039;&#039;&#039; Documento destino
    &#039;&#039;&#039; Certificado a utilizar
    &#039;&#039;&#039; Razón de la firma
    &#039;&#039;&#039; Ubicación
    &#039;&#039;&#039; Establece si hay que agregar la firma visible al documento
    Public Shared Sub SignHashed(ByVal Source As String, ByVal Target As String, ByVal Certificate As SysX509.X509Certificate2, ByVal Reason As String, ByVal Location As String, ByVal AddVisibleSign As Boolean)
        Dim objCP As New X509CertificateParser()
        &#039;NOTA PRUEBAS de X509Certificate (ambiguo &quot;Org.BouncyCastle.X509.X509Certificate()= X509Certificate()&quot;)
        Dim objChain As Org.BouncyCastle.X509.X509Certificate() = New Org.BouncyCastle.X509.X509Certificate() {objCP.ReadCertificate(Certificate.RawData)}

        Dim objReader As New PdfReader(Source)
        Dim objStamper As PdfStamper = PdfStamper.CreateSignature(objReader, New FileStream(Target, FileMode.Create), ControlChars.NullChar)
        Dim objSA As PdfSignatureAppearance = objStamper.SignatureAppearance

        If AddVisibleSign Then
            objSA.SetVisibleSignature(New Rectangle(100, 100, 300, 200), 1, Nothing)
        End If

        objSA.SignDate = DateTime.Now
        objSA.SetCrypto(Nothing, objChain, Nothing, Nothing)
        objSA.Reason = Reason
        objSA.Location = Location
        objSA.Acro6Layers = True
        objSA.Render = PdfSignatureAppearance.SignatureRender.NameAndDescription
        Dim objSignature As New PdfSignature(PdfName.ADOBE_PPKMS, PdfName.ADBE_PKCS7_SHA1)
        objSignature.[Date] = New PdfDate(objSA.SignDate)
        objSignature.Name = PdfPKCS7.GetSubjectFields(objChain(0)).GetField(&quot;CN&quot;)
        If objSA.Reason IsNot Nothing Then
            objSignature.Reason = objSA.Reason
        End If
        If objSA.Location IsNot Nothing Then
            objSignature.Location = objSA.Location
        End If
        objSA.CryptoDictionary = objSignature
        Dim intCSize As Integer = 4000

        &#039;Dim objTable As New Hashtable()
        Dim objTable As New Dictionary(Of PdfName, Integer)
        objTable(PdfName.CONTENTS) = intCSize * 2 + 2
        objSA.PreClose(objTable)

        Dim objSHA1 As HashAlgorithm = New SHA1CryptoServiceProvider()

        Dim objStream As Stream = objSA.RangeStream
        Dim intRead As Integer = 0
        Dim bytBuffer As Byte() = New Byte(8191) {}
        While (InlineAssignHelper(intRead, objStream.Read(bytBuffer, 0, 8192))) &gt; 0
            objSHA1.TransformBlock(bytBuffer, 0, intRead, bytBuffer, 0)
        End While
        objSHA1.TransformFinalBlock(bytBuffer, 0, 0)

        Dim bytPK As Byte() = SignMsg(objSHA1.Hash, Certificate, False)
        Dim bytOut As Byte() = New Byte(intCSize - 1) {}

        Dim objDict As New PdfDictionary()

        Array.Copy(bytPK, 0, bytOut, 0, bytPK.Length)

        objDict.Put(PdfName.CONTENTS, New PdfString(bytOut).SetHexWriting(True))
        objSA.Close(objDict)
    End Sub

    &#039;&#039;&#039; 
    &#039;&#039;&#039; Crea la firma CMS/PKCS #7
    &#039;&#039;&#039; 
    Private Shared Function SignMsg(ByVal Message As Byte(), ByVal SignerCertificate As SysX509.X509Certificate2, ByVal Detached As Boolean) As Byte()
        &#039;Creamos el contenedor
        Dim contentInfo As New ContentInfo(Message)
        &#039;Instanciamos el objeto SignedCms con el contenedor
        Dim objSignedCms As New SignedCms(contentInfo, Detached)
        &#039;Creamos el &quot;firmante&quot;
        Dim objCmsSigner As New CmsSigner(SignerCertificate)
        &#039; Include the following line if the top certificate in the
        &#039; smartcard is not in the trusted list.
        objCmsSigner.IncludeOption = SysX509.X509IncludeOption.EndCertOnly
        &#039;  Sign the CMS/PKCS #7 message. The second argument is
        &#039;  needed to ask for the pin.
        objSignedCms.ComputeSignature(objCmsSigner, False)
        &#039;Encodeamos el mensaje CMS/PKCS #7
        Return objSignedCms.Encode()
    End Function

    Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
        target = value
        Return value
    End Function
End Class</description>
		<content:encoded><![CDATA[<p>Primero Hola JuanFran, yo el tema de &#8220;System.Collections.Hashtable&#8221;/&#8221;System.Collections.Generic.Dictionary&#8221; lo he &#8220;solucionado (a mi me funciona)&#8221; modificando el código.<br />
Te lo dejo en VB.net que es lo que uso:<br />
       &#8216;Dim objTable As New Hashtable()<br />
        Dim objTable As New Dictionary(Of PdfName, Integer)<br />
        objTable(PdfName.CONTENTS) = intCSize * 2 + 2<br />
        objSA.PreClose(objTable)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Hola Gustavo, estoy retomando el proyecto despues de unas vacacione si aún me encuentro algun problema, a ver si puedes ayudarme o cualquiera que pueda echarme una mano.</p>
<p>- Cuando estoy en desarrollo, el proyecto funciona bien (firma el pdf), pero cuando intento publicarlo en el servidor IIS me da algun fallo.<br />
1-. (OPCION 1)Si publico el proyecto en un directorio virtual que SI requiere canal seguro SSL, a la hora de firmar el documento PDF me da el siguiente error:<br />
&#8220;La clave no existe&#8221;<br />
2-. (OPCION 2) Si publico el proyecto en un directorio virtual que NO requiere canal seguro SSL, al intentar acceder a la función GetCertificate me da el siguiente error:<br />
&#8220;The current session is not interactive&#8221;</p>
<p>Os dejo el código en VB.net que estoy usando a ver si alguien da con la solución:</p>
<p>Imports System.Collections<br />
Imports System.IO<br />
Imports System.Security.Cryptography<br />
Imports System.Security.Cryptography.Pkcs<br />
Imports iTextSharp.text<br />
Imports iTextSharp.text.pdf<br />
Imports Org.BouncyCastle.X509<br />
Imports SysX509 = System.Security.Cryptography.X509Certificates</p>
<p>Imports System.Security<br />
Imports System.Security.Cryptography.X509Certificates<br />
Imports System.Security.Cryptography.X509Certificates.X509Certificate2</p>
<p>&#8221;&#8217;<br />
&#8221;&#8217; Helper para el firmado de PDFs con la librería iTextSharp<br />
&#8221;&#8217;<br />
&#8221;&#8217;<br />
Partial Class FirmaDigital02<br />
    Inherits System.Web.UI.Page</p>
<p>    Protected Sub btnSignDigital_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSignDigital.Click<br />
        Try<br />
            &#8221;OPCIÓN 1: DIRECTORIO VIRTUAL IIS con SSL (requerir canal seguro)<br />
            Dim objCertHttp As HttpClientCertificate<br />
            objCertHttp = Request.ClientCertificate<br />
            Dim certificate As X509Certificate2<br />
            certificate = New System.Security.Cryptography.X509Certificates.X509Certificate2(objCertHttp.Certificate)<br />
            &#8216;certificate = New SysX509.X509Certificate2(objCertHttp.Certificate)</p>
<p>            &#8221;OPCIÓN 2: VENTANA SELECCIÓN CERTIFICADO<br />
            &#8216;Dim certificate As X509Certificate2 = GetCertificate()</p>
<p>            Dim source As String = &#8220;C:\Inetpub\wwwroot\TestVB\documents\signats\PruebaSignatura.pdf&#8221;<br />
            Dim target As String = &#8220;C:\Inetpub\wwwroot\TestVB\documents\signats\PruebaSignatura_hashed2.pdf&#8221;<br />
            SignDigital.SignHashed(source, target, certificate, &#8220;Razón&#8221;, &#8220;Localización&#8221;, True)<br />
            lblSignaPDF.Text = &#8220;Finalitzat correctament. Comprobar signa&#8221;<br />
        Catch ex As Exception<br />
            lblSignaPDF.Text = lblSignaPDF.Text &amp; &#8220;Descripció error: &#8221; &amp; ex.Message<br />
        End Try<br />
    End Sub</p>
<p>    Public Shared Function GetCertificate() As X509Certificate2<br />
        Dim st As New X509Store(StoreName.My, StoreLocation.CurrentUser)</p>
<p>        st.Open(OpenFlags.[ReadOnly])<br />
        Dim col As X509Certificate2Collection = st.Certificates<br />
        Dim card As X509Certificate2 = Nothing</p>
<p>        Dim sel As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(col, &#8220;Certificates&#8221;, &#8220;Seleccioni un certificat per a signar&#8221;, X509SelectionFlag.SingleSelection)<br />
        If sel.Count &gt; 0 Then<br />
            Dim en As X509Certificate2Enumerator = sel.GetEnumerator()<br />
            en.MoveNext()<br />
            card = en.Current<br />
        End If<br />
        st.Close()<br />
        Return card<br />
    End Function</p>
<p>    &#8216;Private Sub New()<br />
    &#8216;End Sub<br />
    &#8221;&#8217;<br />
    &#8221;&#8217; Firma un documento<br />
    &#8221;&#8217;<br />
    &#8221;&#8217; Documento origen<br />
    &#8221;&#8217; Documento destino<br />
    &#8221;&#8217; Certificado a utilizar<br />
    &#8221;&#8217; Razón de la firma<br />
    &#8221;&#8217; Ubicación<br />
    &#8221;&#8217; Establece si hay que agregar la firma visible al documento<br />
    Public Shared Sub SignHashed(ByVal Source As String, ByVal Target As String, ByVal Certificate As SysX509.X509Certificate2, ByVal Reason As String, ByVal Location As String, ByVal AddVisibleSign As Boolean)<br />
        Dim objCP As New X509CertificateParser()<br />
        &#8216;NOTA PRUEBAS de X509Certificate (ambiguo &#8220;Org.BouncyCastle.X509.X509Certificate()= X509Certificate()&#8221;)<br />
        Dim objChain As Org.BouncyCastle.X509.X509Certificate() = New Org.BouncyCastle.X509.X509Certificate() {objCP.ReadCertificate(Certificate.RawData)}</p>
<p>        Dim objReader As New PdfReader(Source)<br />
        Dim objStamper As PdfStamper = PdfStamper.CreateSignature(objReader, New FileStream(Target, FileMode.Create), ControlChars.NullChar)<br />
        Dim objSA As PdfSignatureAppearance = objStamper.SignatureAppearance</p>
<p>        If AddVisibleSign Then<br />
            objSA.SetVisibleSignature(New Rectangle(100, 100, 300, 200), 1, Nothing)<br />
        End If</p>
<p>        objSA.SignDate = DateTime.Now<br />
        objSA.SetCrypto(Nothing, objChain, Nothing, Nothing)<br />
        objSA.Reason = Reason<br />
        objSA.Location = Location<br />
        objSA.Acro6Layers = True<br />
        objSA.Render = PdfSignatureAppearance.SignatureRender.NameAndDescription<br />
        Dim objSignature As New PdfSignature(PdfName.ADOBE_PPKMS, PdfName.ADBE_PKCS7_SHA1)<br />
        objSignature.[Date] = New PdfDate(objSA.SignDate)<br />
        objSignature.Name = PdfPKCS7.GetSubjectFields(objChain(0)).GetField(&#8220;CN&#8221;)<br />
        If objSA.Reason IsNot Nothing Then<br />
            objSignature.Reason = objSA.Reason<br />
        End If<br />
        If objSA.Location IsNot Nothing Then<br />
            objSignature.Location = objSA.Location<br />
        End If<br />
        objSA.CryptoDictionary = objSignature<br />
        Dim intCSize As Integer = 4000</p>
<p>        &#8216;Dim objTable As New Hashtable()<br />
        Dim objTable As New Dictionary(Of PdfName, Integer)<br />
        objTable(PdfName.CONTENTS) = intCSize * 2 + 2<br />
        objSA.PreClose(objTable)</p>
<p>        Dim objSHA1 As HashAlgorithm = New SHA1CryptoServiceProvider()</p>
<p>        Dim objStream As Stream = objSA.RangeStream<br />
        Dim intRead As Integer = 0<br />
        Dim bytBuffer As Byte() = New Byte(8191) {}<br />
        While (InlineAssignHelper(intRead, objStream.Read(bytBuffer, 0, 8192))) &gt; 0<br />
            objSHA1.TransformBlock(bytBuffer, 0, intRead, bytBuffer, 0)<br />
        End While<br />
        objSHA1.TransformFinalBlock(bytBuffer, 0, 0)</p>
<p>        Dim bytPK As Byte() = SignMsg(objSHA1.Hash, Certificate, False)<br />
        Dim bytOut As Byte() = New Byte(intCSize &#8211; 1) {}</p>
<p>        Dim objDict As New PdfDictionary()</p>
<p>        Array.Copy(bytPK, 0, bytOut, 0, bytPK.Length)</p>
<p>        objDict.Put(PdfName.CONTENTS, New PdfString(bytOut).SetHexWriting(True))<br />
        objSA.Close(objDict)<br />
    End Sub</p>
<p>    &#8221;&#8217;<br />
    &#8221;&#8217; Crea la firma CMS/PKCS #7<br />
    &#8221;&#8217;<br />
    Private Shared Function SignMsg(ByVal Message As Byte(), ByVal SignerCertificate As SysX509.X509Certificate2, ByVal Detached As Boolean) As Byte()<br />
        &#8216;Creamos el contenedor<br />
        Dim contentInfo As New ContentInfo(Message)<br />
        &#8216;Instanciamos el objeto SignedCms con el contenedor<br />
        Dim objSignedCms As New SignedCms(contentInfo, Detached)<br />
        &#8216;Creamos el &#8220;firmante&#8221;<br />
        Dim objCmsSigner As New CmsSigner(SignerCertificate)<br />
        &#8216; Include the following line if the top certificate in the<br />
        &#8216; smartcard is not in the trusted list.<br />
        objCmsSigner.IncludeOption = SysX509.X509IncludeOption.EndCertOnly<br />
        &#8216;  Sign the CMS/PKCS #7 message. The second argument is<br />
        &#8216;  needed to ask for the pin.<br />
        objSignedCms.ComputeSignature(objCmsSigner, False)<br />
        &#8216;Encodeamos el mensaje CMS/PKCS #7<br />
        Return objSignedCms.Encode()<br />
    End Function</p>
<p>    Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T<br />
        target = value<br />
        Return value<br />
    End Function<br />
End Class
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_198" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c198" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c198" class="gdsr_rating_as"><a id="gdsrX198X5X0XcXcomment_rater_198Xcomment_loader_198" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX198X4X0XcXcomment_rater_198Xcomment_loader_198" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX198X3X0XcXcomment_rater_198Xcomment_loader_198" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX198X2X0XcXcomment_rater_198Xcomment_loader_198" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX198X1X0XcXcomment_rater_198Xcomment_loader_198" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_198" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c198" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Gustavo Cantero (The Wolf)</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-196</link>
		<dc:creator>Gustavo Cantero (The Wolf)</dc:creator>
		<pubDate>Mon, 02 Aug 2010 13:26:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-196</guid>
		<description>Juan, muchas gracias por tus palabras.
Sobre el proyecto, puede ser que tengas una versión distinta del iTextSharp.  Acabo de subir en este mismo artículo un proyecto de ejemplo funcionando para que lo puedas descargar y probar.
Cualquier consulta no dudes en escribir.
Suerte!</description>
		<content:encoded><![CDATA[<p>Juan, muchas gracias por tus palabras.<br />
Sobre el proyecto, puede ser que tengas una versión distinta del iTextSharp.  Acabo de subir en este mismo artículo un proyecto de ejemplo funcionando para que lo puedas descargar y probar.<br />
Cualquier consulta no dudes en escribir.<br />
Suerte!
<div class="ratingblock ">
<div style="display: none">VN:F [1.7.3_972]</div>
<div id="comment_rater_196" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c196" style="width: 60px;" class="gdinner"></div>
<div id="gdr_stars_c196" class="gdsr_rating_as"><a id="gdsrX196X5X0XcXcomment_rater_196Xcomment_loader_196" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX196X4X0XcXcomment_rater_196Xcomment_loader_196" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX196X3X0XcXcomment_rater_196Xcomment_loader_196" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX196X2X0XcXcomment_rater_196Xcomment_loader_196" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX196X1X0XcXcomment_rater_196Xcomment_loader_196" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_196" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c196" class=" comment">Rating: 5.0/<strong>5</strong> (1 voto cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Juan Fran</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-194</link>
		<dc:creator>Juan Fran</dc:creator>
		<pubDate>Sun, 01 Aug 2010 20:28:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-194</guid>
		<description>Hola Gustavo. En primer lugar agradecerte que haya sacado de la oscuridad. Eres un crack!!
Al compilar el codigo me dan los siguientes errores y no se como solucionarlo:

Error	1	La mejor coincidencia de método sobrecargado para &#039;iTextSharp.text.pdf.PdfSignatureAppearance.PreClose(System.Collections.Generic.Dictionary)&#039; tiene algunos argumentos no válidos	

Error	2	Argumento &#039;1&#039;: no se puede convertir de &#039;System.Collections.Hashtable&#039; a &#039;System.Collections.Generic.Dictionary&#039;</description>
		<content:encoded><![CDATA[<p>Hola Gustavo. En primer lugar agradecerte que haya sacado de la oscuridad. Eres un crack!!<br />
Al compilar el codigo me dan los siguientes errores y no se como solucionarlo:</p>
<p>Error	1	La mejor coincidencia de método sobrecargado para &#8216;iTextSharp.text.pdf.PdfSignatureAppearance.PreClose(System.Collections.Generic.Dictionary)&#8217; tiene algunos argumentos no válidos	</p>
<p>Error	2	Argumento &#8217;1&#8242;: no se puede convertir de &#8216;System.Collections.Hashtable&#8217; a &#8216;System.Collections.Generic.Dictionary&#8217;
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_194" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c194" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c194" class="gdsr_rating_as"><a id="gdsrX194X5X0XcXcomment_rater_194Xcomment_loader_194" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX194X4X0XcXcomment_rater_194Xcomment_loader_194" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX194X3X0XcXcomment_rater_194Xcomment_loader_194" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX194X2X0XcXcomment_rater_194Xcomment_loader_194" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX194X1X0XcXcomment_rater_194Xcomment_loader_194" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_194" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c194" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Juan Fran</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-193</link>
		<dc:creator>Juan Fran</dc:creator>
		<pubDate>Sun, 01 Aug 2010 20:19:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-193</guid>
		<description>Hola, Gustavo. En primer lugar agradecerte que hayas dejado este codigo en tu blog. 
Al compilar tu codigo me da el siguiente error 

Error	2	Argumento &#039;1&#039;: no se puede convertir de &#039;System.Collections.Hashtable&#039; a &#039;System.Collections.Generic.Dictionary&#039;	

y la verdad es que estoy un poco perdido.</description>
		<content:encoded><![CDATA[<p>Hola, Gustavo. En primer lugar agradecerte que hayas dejado este codigo en tu blog.<br />
Al compilar tu codigo me da el siguiente error </p>
<p>Error	2	Argumento &#8217;1&#8242;: no se puede convertir de &#8216;System.Collections.Hashtable&#8217; a &#8216;System.Collections.Generic.Dictionary&#8217;	</p>
<p>y la verdad es que estoy un poco perdido.
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_193" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c193" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c193" class="gdsr_rating_as"><a id="gdsrX193X5X0XcXcomment_rater_193Xcomment_loader_193" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX193X4X0XcXcomment_rater_193Xcomment_loader_193" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX193X3X0XcXcomment_rater_193Xcomment_loader_193" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX193X2X0XcXcomment_rater_193Xcomment_loader_193" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX193X1X0XcXcomment_rater_193Xcomment_loader_193" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_193" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c193" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Gustavo Cantero (The Wolf)</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-174</link>
		<dc:creator>Gustavo Cantero (The Wolf)</dc:creator>
		<pubDate>Thu, 15 Jul 2010 15:07:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-174</guid>
		<description>Tienes razón, Álvaro, acabo de actualizar el código, me había faltado un método que justamente es el que crea la firma.
Después cuéntame cómo te anduvo.
Saludos.</description>
		<content:encoded><![CDATA[<p>Tienes razón, Álvaro, acabo de actualizar el código, me había faltado un método que justamente es el que crea la firma.<br />
Después cuéntame cómo te anduvo.<br />
Saludos.
<div class="ratingblock ">
<div style="display: none">VN:F [1.7.3_972]</div>
<div id="comment_rater_174" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c174" style="width: 60px;" class="gdinner"></div>
<div id="gdr_stars_c174" class="gdsr_rating_as"><a id="gdsrX174X5X0XcXcomment_rater_174Xcomment_loader_174" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX174X4X0XcXcomment_rater_174Xcomment_loader_174" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX174X3X0XcXcomment_rater_174Xcomment_loader_174" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX174X2X0XcXcomment_rater_174Xcomment_loader_174" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX174X1X0XcXcomment_rater_174Xcomment_loader_174" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_174" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c174" class=" comment">Rating: 5.0/<strong>5</strong> (1 voto cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Alvaro Pardo</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-173</link>
		<dc:creator>Alvaro Pardo</dc:creator>
		<pubDate>Thu, 15 Jul 2010 12:53:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-173</guid>
		<description>Hola Gustavo,

Estamos probando a utilizar tu ejemplo, pero nos da error al compilarlo... ya que el método SingMsg no está definido.

¿Podrías añadirlo al ejemplo? 

Muchas gracias</description>
		<content:encoded><![CDATA[<p>Hola Gustavo,</p>
<p>Estamos probando a utilizar tu ejemplo, pero nos da error al compilarlo&#8230; ya que el método SingMsg no está definido.</p>
<p>¿Podrías añadirlo al ejemplo? </p>
<p>Muchas gracias
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_173" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c173" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c173" class="gdsr_rating_as"><a id="gdsrX173X5X0XcXcomment_rater_173Xcomment_loader_173" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX173X4X0XcXcomment_rater_173Xcomment_loader_173" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX173X3X0XcXcomment_rater_173Xcomment_loader_173" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX173X2X0XcXcomment_rater_173Xcomment_loader_173" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX173X1X0XcXcomment_rater_173Xcomment_loader_173" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_173" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c173" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: darmowe e booki</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-168</link>
		<dc:creator>darmowe e booki</dc:creator>
		<pubDate>Tue, 06 Jul 2010 09:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-168</guid>
		<description>&lt;strong&gt;darmowe e booki...&lt;/strong&gt;

I was interested in your article. Well, there are some people who are able to present this issue in such a way. I wish you continued success and looks forward to further articles....</description>
		<content:encoded><![CDATA[<p><strong>darmowe e booki&#8230;</strong></p>
<p>I was interested in your article. Well, there are some people who are able to present this issue in such a way. I wish you continued success and looks forward to further articles&#8230;.
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_168" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c168" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c168" class="gdsr_rating_as"><a id="gdsrX168X5X0XcXcomment_rater_168Xcomment_loader_168" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX168X4X0XcXcomment_rater_168Xcomment_loader_168" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX168X3X0XcXcomment_rater_168Xcomment_loader_168" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX168X2X0XcXcomment_rater_168Xcomment_loader_168" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX168X1X0XcXcomment_rater_168Xcomment_loader_168" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_168" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c168" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Alberto Pérez</title>
		<link>http://www.programandoamedianoche.com/2010/06/como-firmar-un-documento-pdf-desde-c-sharp-con-itextsharp/comment-page-1/#comment-163</link>
		<dc:creator>Alberto Pérez</dc:creator>
		<pubDate>Fri, 25 Jun 2010 08:57:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.programandoamedianoche.com/?p=1063#comment-163</guid>
		<description>Hola Gustavo... espero no me odies, pero sigo con el mismo problema... &quot;La clave no existe&quot;  AHGG!!.

No sé que es lo que hago mal, pero en local me funciona y en el servidor no.
La diferencia entre estas dos pruebas es la manera de obtener el certificado.
En local (a través de la función &quot;GetCertificate&quot; de iTextSharp).
En el servidor a través del Request.ClientCertificate indicando al IIS Requerir Canal Seguro SSL y Requerir certificado cliente.

&quot;Dim objCertHttp As HttpClientCertificate
objCertHttp = Request.ClientCertificate
Dim certificate As X509Certificate2
certificate = New System.Security.Cryptography.X509Certificates.X509Certificate2(objCertHttp.Certificate)&quot;

A la hora de llamar a la función:            
PDF.SignHashed(source, target, certificate, &quot;Razón&quot;, &quot;Localización&quot;, True)

Donde source es &quot;C:\Inetpub\wwwroot\documentos\Prueba.pdf&quot; y la carpeta documentos con permisos de escritura, lectura.
y target &quot;C:\Inetpub\wwwroot\documentos\Prueba_sign.pdf&quot;

Me persigue el error: &quot;LA CLAVE NO EXISTE&quot;.
Creo que en local la clave existe porque cuando le doy al botón de firmar me pide el certificado (funcion getCertificate), mientras que en el servidor cuando entro en la página es cuando me pide el certificado (Request.ClientCertificate) (por el SSL de IIS) y me pide la clave, despues he de picar al botón de firmar y da el error.

Por favor... ya se que abuso, pero necesito algo de luz!.
Saludos</description>
		<content:encoded><![CDATA[<p>Hola Gustavo&#8230; espero no me odies, pero sigo con el mismo problema&#8230; &#8220;La clave no existe&#8221;  AHGG!!.</p>
<p>No sé que es lo que hago mal, pero en local me funciona y en el servidor no.<br />
La diferencia entre estas dos pruebas es la manera de obtener el certificado.<br />
En local (a través de la función &#8220;GetCertificate&#8221; de iTextSharp).<br />
En el servidor a través del Request.ClientCertificate indicando al IIS Requerir Canal Seguro SSL y Requerir certificado cliente.</p>
<p>&#8220;Dim objCertHttp As HttpClientCertificate<br />
objCertHttp = Request.ClientCertificate<br />
Dim certificate As X509Certificate2<br />
certificate = New System.Security.Cryptography.X509Certificates.X509Certificate2(objCertHttp.Certificate)&#8221;</p>
<p>A la hora de llamar a la función:<br />
PDF.SignHashed(source, target, certificate, &#8220;Razón&#8221;, &#8220;Localización&#8221;, True)</p>
<p>Donde source es &#8220;C:\Inetpub\wwwroot\documentos\Prueba.pdf&#8221; y la carpeta documentos con permisos de escritura, lectura.<br />
y target &#8220;C:\Inetpub\wwwroot\documentos\Prueba_sign.pdf&#8221;</p>
<p>Me persigue el error: &#8220;LA CLAVE NO EXISTE&#8221;.<br />
Creo que en local la clave existe porque cuando le doy al botón de firmar me pide el certificado (funcion getCertificate), mientras que en el servidor cuando entro en la página es cuando me pide el certificado (Request.ClientCertificate) (por el SSL de IIS) y me pide la clave, despues he de picar al botón de firmar y da el error.</p>
<p>Por favor&#8230; ya se que abuso, pero necesito algo de luz!.<br />
Saludos
<div class="ratingblock ">
<div style="display: none">VA:F [1.7.3_972]</div>
<div id="comment_rater_163" class="ratecmm">
<div class="starsbar">
<div class="gdouter" align="left">
<div id="gdr_vote_c163" style="width: 0px;" class="gdinner"></div>
<div id="gdr_stars_c163" class="gdsr_rating_as"><a id="gdsrX163X5X0XcXcomment_rater_163Xcomment_loader_163" title="5 out of 5" class="s5" rel="nofollow"></a><a id="gdsrX163X4X0XcXcomment_rater_163Xcomment_loader_163" title="4 out of 5" class="s4" rel="nofollow"></a><a id="gdsrX163X3X0XcXcomment_rater_163Xcomment_loader_163" title="3 out of 5" class="s3" rel="nofollow"></a><a id="gdsrX163X2X0XcXcomment_rater_163Xcomment_loader_163" title="2 out of 5" class="s2" rel="nofollow"></a><a id="gdsrX163X1X0XcXcomment_rater_163Xcomment_loader_163" title="1 out of 5" class="s1" rel="nofollow"></a></div>
</div>
</div>
</div>
<div id="comment_loader_163" style="display: none; width:60px;" class="ratingloadercomment">
<div class="loader flower " style="height: 12px">
<div class="loaderinner">aguarde un momento...</div>
</div>
</div>
<div id="gdr_text_c163" class=" comment">Rating: 0.0/<strong>5</strong> (0 votos cast)</div>
</div>
]]></content:encoded>
	</item>
</channel>
</rss>

