ERRO NA TRANSMISSÃO DO CTE 4.0

PROSOFT 14/02/2024 07:20:41
#503043
Bom Dia Pessoal

A algum tempo desenvolvi um aplicativo pra emissão de CTE. Não tenho muitos clientes que usam, mas funcionava direitinho. Acontece que essa semana fui surpreendido com o fim da versão 3.00 e a consequente necessidade de migração para a versão 4.0
Pelo que vi, mudou a forma de envio do xml que deve estar compactado e na base 64 string
Uso esse código que fiz bem detalhado pra facilitar o entendimento

Dim NomeArq As String = "C:\Lixo\Fretes-CTe.XML"
Dim ArqZip As String = "C:\Lixo\Fretes-CTe.GZ"

Dim StreamOri As New FileStream(NomeArq, FileMode.Open, FileAccess.Read)
' ----- Cria a saida do arquivo stream
Dim StreamDest As New FileStream(ArqZip, FileMode.Create, FileAccess.Write)
Dim StreamZip As New GZipStream(StreamDest, CompressionMode.Compress, True)

' ----- Compacto o XML para o arquivo GZ
Const tamanhoBloco As Integer = 4096
Dim buffer(tamanhoBloco) As Byte
Dim bytesLidos As Integer
Do
bytesLidos = StreamOri.Read(buffer, 0, tamanhoBloco)
If (bytesLidos = 0) Then Exit Do
StreamZip.Write(buffer, 0, bytesLidos)
Loop
StreamOri.Close()
StreamZip.Close()
StreamDest.Close()

'Leio o arquico compactado para um vetor de bytes
Dim F As New FileInfo(ArqZip)
Dim Bytes As Long = F.Length
Dim Fs As New FileStream(ArqZip, FileMode.Open, FileAccess.Read)
Dim Br As New BinaryReader(Fs)
Dim Dados As Byte() = Br.ReadBytes(CInt(Bytes))
Br.Close()
Fs.Close()

'Converto o vetor de bytes para uma string base 64
Dim TxtXML As String = Convert.ToBase64String(Dados)

Ao enviar a SEFAZ a string compactada recebo a seguinte mensagem de retorno:

Erro Num: 244
Falha na descompactação da área de dados


Penso que o erro acontece por uma das seguintes razões:
1 - A string na base 64 está mal gerada;
2 - Algum erro no CML que envio

Em anexo estou enviando uma cópia do XML que estou compactando e transmitindo

Ficaria muito, mas muito grato mesmo se alguém puder me dar uma luz
PROSOFT 14/02/2024 07:26:55
#503044
Não aceitou anexar o arquivo. Estou postando o XML

<?xml version="1.0" encoding="UTF-8"?>
<enviCTe xmlns="http://www.portalfiscal.inf.br/cte" versao="4.00">
<idLote>1</idLote>
<CTe xmlns="http://www.portalfiscal.inf.br/cte">
<infCte Id="CTe43240207444112000180570020000001051868852074" versao="4.00">
<ide>
<cUF>43</cUF>
<cCT>86885207</cCT>
<CFOP>5353</CFOP>
<natOp>TRANSPORTE A ESTABELECIMENTO COMERCIAL</natOp>
<mod>57</mod>
<serie>2</serie>
<nCT>105</nCT>
<dhEmi>2024-02-13T15:01:52-02:00</dhEmi>
<tpImp>1</tpImp>
<tpEmis>1</tpEmis>
<cDV>4</cDV>
<tpAmb>1</tpAmb>
<tpCTe>0</tpCTe>
<procEmi>0</procEmi>
<verProc>6.1</verProc>
<cMunEnv>4316907</cMunEnv>
<xMunEnv>SANTA MARIA</xMunEnv>
<UFEnv>RS</UFEnv>
<modal>01</modal>
<tpServ>0</tpServ>
<cMunIni>4316907</cMunIni>
<xMunIni>SANTA MARIA</xMunIni>
<UFIni>RS</UFIni>
<cMunFim>4306932</cMunFim>
<xMunFim>ENTRE-IJUÍS</xMunFim>
<UFFim>RS</UFFim>
<retira>0</retira>
<indIEToma>1</indIEToma>
<toma3>
<toma>0</toma>
</toma3>
</ide>
<compl />
<emit>
<CNPJ>07444112000180</CNPJ>
<IE>00001090328955</IE>
<xNome>ANDERSON GOEBEL COLPO</xNome>
<xFant>ANDERSON GOEBEL COLPO</xFant>
<enderEmit>
<xLgr>RUA ANTONIO G. DO AMARAL</xLgr>
<nro>2500</nro>
<xBairro>CAMOBI</xBairro>
<cMun>4316907</cMun>
<xMun>SANTA MARIA</xMun>
<CEP>97110000</CEP>
<UF>RS</UF>
<fone>55999618095</fone>
</enderEmit>
</emit>
<rem>
<CNPJ>88616776000858</CNPJ>
<IE>00001090403795</IE>
<xNome>MECASUL</xNome>
<xFant>MECASUL AUTO MECANICA S.A</xFant>
<fone>5530271700</fone>
<enderReme>
<xLgr>ROD BR 158 SALA 03</xLgr>
<nro>1000</nro>
<xBairro>KM 3</xBairro>
<cMun>4316907</cMun>
<xMun>Santa Maria</xMun>
<CEP>97095800</CEP>
<UF>RS</UF>
<cPais>1058</cPais>
<xPais>BRASIL</xPais>
</enderReme>
</rem>
<exped>
<CNPJ>07444112000180</CNPJ>
<IE>00001090328955</IE>
<xNome>ANDERSON GOEBEL COLPO</xNome>
<fone>55999618095</fone>
<enderExped>
<xLgr>RUA ANTONIO G. DO AMARAL</xLgr>
<nro>2500</nro>
<xBairro>CAMOBI</xBairro>
<cMun>4316907</cMun>
<xMun>SANTA MARIA</xMun>
<CEP>97110000</CEP>
<UF>RS</UF>
<cPais>1058</cPais>
<xPais>BRASIL</xPais>
</enderExped>
</exped>
<dest>
<CNPJ>88616776000777</CNPJ>
<IE>00002690010601</IE>
<xNome>MECASUL AUTO MECANICA S.A ENTRE IJUIS</xNome>
<fone>5533292599</fone>
<enderDest>
<xLgr>AV DO TRABALHADOR</xLgr>
<nro>65</nro>
<xBairro>CENTRO</xBairro>
<cMun>4306932</cMun>
<xMun>Entre-Ijuís</xMun>
<CEP>98855000</CEP>
<UF>RS</UF>
<cPais>1058</cPais>
<xPais>BRASIL</xPais>
</enderDest>
</dest>
<vPrest>
<vTPrest>34.00</vTPrest>
<vRec>34.00</vRec>
</vPrest>
<imp>
<ICMS>
<ICMS00>
<CST>00</CST>
<vBC>34.00</vBC>
<pICMS>18.00</pICMS>
<vICMS>6.12</vICMS>
</ICMS00>
</ICMS>
</imp>
<infCTeNorm>
<infCarga>
<vCarga>42.00</vCarga>
<proPred>AMORTECEDOR,CJ CONSOLE TR</proPred>
<infQ>
<cUnid>03</cUnid>
<tpMed>UNIDADE</tpMed>
<qCarga>1.0000</qCarga>
</infQ>
</infCarga>
<infDoc>
<infNFe>
<chave>43231088616776000858550000000870071361048969</chave>
</infNFe>
</infDoc>
<infModal versaoModal="4.00">
<rodo>
<RNTRC>10302999</RNTRC>
</rodo>
</infModal>
</infCTeNorm>
</infCte>
<infCTeSupl>
<qrCodCTe><![CDATA[https://dfe-portal.svrs.rs.gov.br/cte/qrCode?chCTe=43240207444112000180570020000001051868852074&tpAmb=1]]></qrCodCTe>
</infCTeSupl>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="#CTe43240207444112000180570020000001051868852074">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>/+FEXGVYd6qnk7RTEMlru0e0KrA=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>MmGRGM3kDAwSssAOSsw/SixIWovNpg9D6cMjV0H4j3uWLGAAaHAd+EZD2bITcUmUBUVbaPIbLteS1ieHbBlrjaY9uvuaH9mALbnvpTdZtGRRlA89HyocBibQJZqobqt0oRjSazYVZQfSFyGYdiIcxuOZvU0hW9dgXr8jK289/ucf+6MlIE96O6hO6x5L87WPcGGTsmzopuxjjQNlx43VsN7pbh0hDWoBYX3aTUMG56Z8bK8UzTrTEza72z4uV+uwgV/QjIEC1Uct5mIW/sAp7mCpYUiZS+8RurnToDLoZjHw+C56WbD2nicEFNcBI4l3ZytKWGDGqzZvs4IAyh4IDg==</SignatureValue>
<KeyInfo>
<X509Data>
<X509Certificate>MIIIAjCCBeqgAwIBAgIIM7AX8jKkHgEwDQYJKoZIhvcNAQELBQAwdDELMAkGA1UEBhMCQlIxEzARBgNVBAoTCklDUC1CcmFzaWwxNjA0BgNVBAsTLVNlY3JldGFyaWEgZGEgUmVjZWl0YSBGZWRlcmFsIGRvIEJyYXNpbCAtIFJGQjEYMBYGA1UEAxMPQUMgVkFMSUQgU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mrOfCt5TCWWow0GnTwMre4LZoLSEQiXO5daxpUsHnYqJ6/wcVf+wvBgirVf0r+ZeNlCtDzH/CR79Jby7odgz29eS0XK/dBsKVR6pGqg5A+fuDxWIHirappywq2ALaq5zRqmlCDbddQN8u4JTqT6qKD+mpvdSafi0QT0kqys1sKScM78qe8bfCHusElU/+u2KNm8q0U0Y06R9C0lcuqRvAziUN4tR2VPuF7EioMfr6JCpfbSe4eWGOIvlXoEmAPX853DBowW+5A66auFUtUUoY37m6XdEgdiU/Z8htAOPbAZ0xTMCFZi5uQPp0V0lHLMKGzLYQtuNMWPgVhiPAJumTFDxtA5q37CPBDZ+z5SfZ4LWVdVblQ6UiOpp8PyS8Yu5ChFgm+ZE1hZAQ5/c0qrVxW3E8KcErSEFugKWnPc8N9yZ8c=</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</CTe>
</enviCTe>
PROSOFT 20/02/2024 07:58:21
#503083
Esse problema foi resolvido
Tópico encerrado , respostas não são mais permitidas